2

I am trying to automate a click to page 2 of a database that runs asynchronously on a webpage. When using the Xpath:

//id('standardView')/x:div[3]/x:div[3]/x:a[1]

I get the following error:

[error] Invalid xpath [2]: //id('rightMenu')/x:div[3]/x:div[3]/x:a[1]

So I tried using DOM to find its path, and the below code brings up the actual link being pushed when run with Firebug...

   main = document.getElementById("rightMenu"); mainCont = main.contentDocument;
   paging = mainCont.getElementsByTagName("a"); pageTwo = paging[0];

Firebug will show:

<a href="javascript:chgPage(2);">

but Selenium is throwing this error:

[error] Unexpected Exception: fileName -> chrome://selenium-ide/content/selenium-
core/scripts/selenium-api.js, lineNumber -> 2535, columnNumber -> 45

And just plain 'ol recording the action isn't picking up that the button is being pressed. I can't seem to find a workaround solution. Any insight, my friends?

1
  • Can you post a snippet of the html? Commented Mar 22, 2013 at 14:45

1 Answer 1

2

Kinda strange xpath. Try to use //*[@id='standardView']/div[3]/div[3]/a[1]

But try to use selectors without indexes and as short as possible

//a[@href='javascript:chgPage(2);']

or

//*[@id='standardView']//a[@href='javascript:chgPage(2);']

These ones can work as well (if they're unique, check this with firepath plugin for firebug)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Alexander! I used //a[@href='javascript:chgPage(2);'] and it worked perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.