Selenium RC Problems with XPath

I am using Selenium RC with chrome mode for Firefox to automate test cases for a web application. I write scripts in Java using TestNG and Eclipse. Now to the main thing:

I'm having problems with Selenium RC for recognizing certain XPath. I am checking my XPaths with the XPath-Checker extension for Firefox, which shows no errors. Then I test it in the Selenium IDE to make sure XPath is recognized. Even the IDE recognizes the element. But his Selenium RC just does not recognize. Is there anything I can do to fix this?

In particular, I am trying to click on a specific 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']

Nothing yet!

1) Can anyone suggest what might be wrong, or is Selena known to have XPath problems?

2) ( XPath checker), , Selenium RC? , , RC XPaths.

,
Mugen

:

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");

, , ( ), .

HTML :

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

, .: -)

+5
5

, div title. , ?

, css- , :

css=div[title='Automated User']
+6

XPath Selenium Firefox.

  • ?
  • , (*), . .

    //* [@ = 'someid1']/* [@ class= 'SomeClass']/* [@ = 'someid2']

+2

:

selenium.click("id=someid4");

, , .

, xpath :

selenium.click("//div[@title='required title']");

:

selenium.click("css=div[title='required title']");
selenium.click("css=.someclass:nth-child(4)"); //must be 4th child of parent element

div ? ? , , . , :

mouseDown
mouseUp
fireEvent
+2
source

Are you sure that the page is loaded correctly using RC, i.e. Do you see the browser open and the page loading?

0
source

Perhaps your script is faster than a webpage. Try to wait a while. how can you usewaitForCondition("selenium.isElementPresent("ElementID")","20000");

As nothg worng seems with xpath.try, this may help you.

0
source

All Articles