1 Star2 Stars3 Stars4 Stars5 Stars
Loading ... Loading ...

By Arun Motoori

XPath statement can be used to locate more than one element. In order to retrieve the number of elements located by a single XPath statement, we have to use getXpathCount Selenium RC command.So lets find an XPath statement which locates more than one element by following the below steps:1. Open in Firefox Browser2. In ‘Firepath’ tab, select XPath option and enter the XPath statement //option into the text box field as shown below:

3. So the XPath Statement //option can locate more than one element (i.e. all the list options in the drop down field)Test Description:Go through the comments mentioned on the below screenshot to understand the test description that we are going to implement on Eclipse IDE:
Syntax:getXpathCount(“XPath Statement”);Lets Implement This:Pre-requisites:1. Create a new Project say ‘RC-Project60’ in Eclipse IDE2. Configure the Project to work with Selenium RC3. Configure the Selenium Standalone Server to run from Eclipse IDE4. Create a package say ‘package60’ under the newly created project.5. Create a Java Class file say ‘Class60’ under the newly created package as shown below:
Actual Steps:1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:
2. Write the test method ‘getXpathCountDemo()’ as shown below:
3. Use Selenium RC command getXPathCount( ) for retrieving the count of the list options available in the drop down field and also enter the retrieved count into the text area field using the Selenium RC command type as shown below:

Note – intValue( ) Java method is used in this example to convert the number returned by the getXpathCount Selenium RC command to an integer value.4. Start the Selenium Standalone Server5. Save and Run the ‘’ file by selecting the ‘JUnit Test’ option and ensure that our Automation Test has retrieved the count of list options in the drop down field using getXpathCount command, converted the count into the integer value using intValue( ) Java method and entered the converted count into the text area field using type Selenium RC command as shown in the below video:Watch the below video:Click here to watch the video.Download this Project:
Click here to download this project and import into Eclipse IDE on your machine. Please comment below to feedback or ask questions.
Using getBodyText command will be explained in the next post.


Category: aafn. 144. Using getXpathCount command

Você também pode querer ler

Comments are off for this post.