Saturday, 2 June 2012

Fetching or Verifying text or value from web page in selenium RC

Generally Verification looks easy when we use selenium IDE , but it looks complex to write appropriate method for fetching or retrieving value.

GetText and GetValue methods are two important methods which deals with fetching and retrieving value from webpage.

GetText (Gets the text of an element.It is very useful when we try to fetch or verify value from SPAN,DIV

    Syntax:         public java.lang.String getText(java.lang.String locator)
    Parameters:     locator - an Element Locator
    Returns:        The text of the element

Example:
        stextToVerify=selenium. GetText   (Locator)

GetValue (Gets the text of an element.It is very useful when we try to fetch or verify value from Webedit,checkbox,radio button,... 
    Syntax:         public java.lang.String getValue(java.lang.String locator)
    Parameters:     locator - an Element Locator
    Returns:        the element value, or "on/off" for checkbox/radio

Example:
        sValueToVerify=selenium. GetValue (Locator)

NOTE:-  where selenium is the object of DefaultSelenium  class


1 comment:

  1. Good post!
    Thanks for sharing this information..
    post more articles like this...
    Hamsini Technologies providing Tableau Online Training in Hyderabad, India with live projects and real time scenarios. We have highly dedicated and real time industry experts as our faculty.
    Best Selenium Online Training

    ReplyDelete