• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Ujjwal Patil
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

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

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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!