Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

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 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.


## 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/ 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