views:

72

answers:

1
+2  Q: 

Regarding XPath

When i am checking an XPath of a link, it appears to be:

id('content')/x:table/x:tbody/x:tr/x:td[2]/x:table/x:tbody/x:tr[2]/x:td[1]/x:table/x:tbody/x:tr[2]/x:td/x:table/x:tbody/x:tr[2]/x:td/x:table/x:tbody/x:tr[1]/x:td/x:table/x:tbody/x:tr/x:td/x:table/x:tbody/x:tr[2]/x:td/x:table/x:tbody/x:tr/x:td[4]/x:a[2]

How can I use it in in target?

If I copy it directly, it doesn't give a result. What else can be done in this regard?

+2  A: 

With Selenium, if the locator starts with // then it is assumed that the locator is an XPath, in your case the you will need to precede your locator with xpath= to make it explicit.

That said, your XPath looks very fragile. You might find that one of the other supported locator types would be more suitable, or a simplified XPath.

Dave Hunt
Instead of Xpath if i want to check for Css, how can i do so?
shoaib
Here's a good resource for CSS selectors in Selenium: http://saucelabs.com/blog/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/ I wouldn't be able to provide a working example without more information on your HTML source.
Dave Hunt
have worked a lot with that, used firebug to cater that problem and to generate a more simplified XPATH, and now amazingly its working. Thanks a lot for your help Dave :)
shoaib