When we use selenium command at that time command not find and attribute not get? See below command.
<table>
<tr><td>open</td><td>http://www.wikipedia.org/</td><td></td></tr>
<tr><td>verifyAttribute</td><td>css=input#searchInput</td><td>(Search Input)</td></tr>
<tr><td>assertAttribute</td><td>css=input#searchInput</td><td>(Search Input)</td></tr>
<tr><td>verifyAttribute</td><td>css=input#searchInput</td><td>language</td></tr>
<tr><td>verifyAttribute</td><td>xpath=//div[2]@class central-featured</td><td>central-featured</td></tr>
<tr><td>verifyAttribute</td><td>xpath=//div[2]@class central-featured</td><td>search1</td></tr>
<tr><td>assertAttribute</td><td>xpath=//div[2]@class central-featured</td><td>central-featured</td></tr>
</table>
I am using Selenium IDE 2.5.0 in Mozilla Firefox and Ubuntu.
Xpath
//div[2]@class central-featured
is invalid. Try changing it to//div[@class='central-featured']/@class
if you mean to select a class. You could also useassertElementPresent
function instead of selecting attribute, if the whole point is to check that element exists, i.e.:<tr><td>assertElementPresent</td><td>xpath=//div[@class='central-featured']</td><td></td></tr>
Much simpler that way.Here it is you have copied the xPath for that specific element. This is shown in the image:
Click to see how to copy xPath
The Xpath you have used in Invalid.
You can use xpath as follows and through this you can fins xpath of any object - just need to study the concept:
Here as we can see we want to search Google Search just by writing its xpath in console So to find the Google Search button we have to write xpath like this
Once we hit enter it would bring
It shows that xpath for Google Search Button is correctly written
Now suppose we want to search Google Search button if we are just familiar that id attributes start with gbqfs
then we have to use function starts-with like this
and once when we hit enter on console it would reflect two button one is Google Searchand Second one is I’m Feeling Lucky
So to find out the Google Search uniquely we need to complete id attribute to gbqfsa
and hit to enter and now it would reflect only
It proves that we have written right xpath for Google Search
In the same fashion we can use Contains function to find the Google Search button like this here I have taken fsa from gbqfsa
//span[contains(@id,'fsa')]
hit enter and hopefully it will return
if there are multiple attributes then we can use:
//span[contains(@id,'fsa') and contains(@class, 'xyz')]
hit enter and hopefully it will returnInformation Source: Sumit Mittal Blog
You can use CssSelector as below