aspose file tools*
The moose likes Testing and the fly likes Testing with Selenium Webdriver: How to use Xpath from properties files ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Testing with Selenium Webdriver: How to use Xpath from properties files ? " Watch "Testing with Selenium Webdriver: How to use Xpath from properties files ? " New topic
Author

Testing with Selenium Webdriver: How to use Xpath from properties files ?

Ujjwal Patil
Greenhorn

Joined: Mar 13, 2013
Posts: 1
Hello All,

I am fairly new to java and selenium testing. I am trying to set the framework, where I can save all the xpaths in xpath.properties( like object repository) and use it in all scripts.

But, I am not sure how to use it in the scripts. Can anyone please guide me how to use these values.

Here is my sample code.

## xpath.properties
phonesystem=//a[@id='menu_topNav_Id:j_idt77:1:j_idt79']

## script code
Properties prop = new Properties();
FileInputStream ip = new FileInputStream("C:\\Automation\\workspace\\TestNG Project\\src\\Config\\Config.Properties");
prop.load(ip);
String phonesystem = prop.getProperty("phonesystem");
driver.findElement(By.xpath("phonesystem")).click();

When I run the script, I get following error.
org.openqa.selenium.InvalidSelectorException: The given selector "//a[@id='menu_topNav_Id:j_idt77:1:j_idt79']" is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression "//a[@id='menu_topNav_Id:j_idt77:1:j_idt79']" because of the following error:
[Exception... "The expression cannot be converted to return the specified type." code: "0" nsresult: "0x805b0034 (TypeError)" location: "file:///C:/Users/upatil/AppData/Local/Temp/anonymous2337003882435725061webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js Line: 5696"]
Command duration or timeout: 18 milliseconds


I am sure I am doing it wrong somehow, can someone please help me ?
I will really appreciate if any could help me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Testing with Selenium Webdriver: How to use Xpath from properties files ?
 
Similar Threads
Is there any method to handle multiple windows using selenium or webdriver?
HSSF
how to select an image from a list of images using selenium
Junit4+Eclipse+Selenium RC- Test class should have exactly one public zero-argument constructor
Selenium grid-1.0.8 and Safari 5 browser