1

Have to inspect element 8. When click the element 8 on webpage.It should redirects to next page

<td class="text_overflow-1">
<u>
<a targrt="_parent();" href="subscriberall.php?key=138">8</a>
</u>
</td>

I have tried the following locators

  //a[@href="subscriberall.php?key=138"]
  driver.findElement(By.linkText("8")).click();

When run the above code in selenium webdriver. What actually happened means, it inspects element 8. But it doesnot clickable to next page

  • What do you mean it doesnot clickable to next page? Do you want to jump to next page? – demouser123 Dec 26 '15 at 12:19
  • Yes want to jumb to next page. But its not function, when tried the above locators – josh test Dec 26 '15 at 12:38
  • Next page- is it in same tab or other- or any other window? – demouser123 Dec 26 '15 at 12:45
  • When click 8, it redirects to same tab. – josh test Dec 26 '15 at 13:33
  • Bit late, but which browser? I have some versions of Internet Explorer seen to not register the first click correctly, this was because of the wrong focus. Clicking twice could help here :) – Niels van Reijmersdal Sep 6 '16 at 7:28
1

NOTE: You should ask your developers to put in a unique id in the page element so that it will be reusable. The attributes you have now will not suffice.

Usually an element is not clickable if you don't associate your page object to the a tag. So, when your developer adds a unique id into the a tag (let's say id = unique) then this should work.

driver.findElement(By.cssSelector("u a[id='unique']")).click();
| improve this answer | |
1
//a[@href="subscriberall.php?key=138"]
driver.findElement(By.linkText("8")).click();

There could be a variety of reasons why the above locators do not work. I also noticed a typo in

<a targrt="_parent();"...

It would be very advantageous to check your error log from the IDE/Terminal and copy/paste them so we can get a better idea of what specific issue you are having with the locators. If the element cannot be found that could mean the xpath query you wrote above has a dynamic key=XXX which is very brittle. In this case you may want to change it to

//u/a[contains(@href, 'subscriberall.php?key=')]
| improve this answer | |
1

You can try following xpath

//div[@class='text_overflow-1']/u/a

driver.findElement(By.xpath("//div[@class='text_overflow-1']/u/a")).click();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.