I'm using Selenium RC with chrome-mode for Firefox to automate test cases for a web application. I'm writing the scripts in Java using TestNG framework and Eclipse. Now to the main point:
I'm having problems with Selenium RC for recognizing certain XPaths. I validate my XPaths with XPath-Checker extension for Firefox which shows no error. I then try it out in Selenium IDE to make sure that XPath is being recognized. Even IDE recognizes the element. But its the Selenium RC just doesnt recognize it. Is there anything I can do to correct this?
Specifically, I'm trying to click on a particular area given by:
html/body/form/div[@id='someid1']/div[@class='someClass']/div[@id='someid2']/div[@id='someid3']/div[@id='someid4']/div[@title='titleOfTheElement']
Then I also tried:
//div[@title='titleOfTheElement']
xpath=//div[@title='Automated User']
xpath=/descendant::div[@title='Automated User']
Still nothing!
1) Can someone please suggest what could be wrong, or whether Selenium is known to have problems with XPath?
2) Isn't there any addon (similar to XPath checker) that helps us to see things the way Selenium RC sees? This way we could be sure whether RC is going to recognize the XPaths.
Thanks,
Mugen
Here is the Selenium code:
selenium.click("somelink");
selenium.waitForPageToLoad("30000");
boolean flag=false
do{
if (selenium.isTextPresent("Some text on the page which loads last"))
{
flag=true
}
}while(flag=false);
selenium.click("locator for area which is driving me crazy");
Now at the last step if I were to click anywhere else on the page (meaning some other locator) the click would work.
The HTML for the area looks like this:
<div id="someid1" style="overflow: hidden;">
<div id="someid2" title="title1" class="someclass">title1</div>
<div id="someid3" title="title2" class="someclass">title2</div>
<div id="someid4" title="required title" class="someclass">required title</div>
<div id="someid5" title="title3" class="someclass">title3</div>
<div id="someid6" title="title4" class="someclass">title4</div>
<div id="someid7" title="title5" class="someclass">title5</div></div>
Thanks a load for looking into this. :-)
I'm not sure if it's correct to have a div with a title attribute. Isn't there another attribute you could use to locate the element?
Anyway, here's the css version of the locator, in case it works:
css=div[title='Automated User']
We had once an issue with XPath expressions when running Selenium tests on Firefox.
I remember we replaced all element names with asterisk signs (*
) and that helped. i.e.
//*[@id='someid1']/*[@class='someClass']/*[@id='someid2']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With