1

I am having difficulty clicking a Javascript:void(0) button with an "x" text in Selenium Java.

<a href="javascript:void(0);" class="aui-button aui-button-link aui-restfultable-delete aui-restfultable-delete-small" original-title="Delete resolved">x</a>

It is a small x button that opens up another window to confirm delete but I am unable to get to the confirm window in Selenium using Java.

At the moment I have used the below but all came up with errors.

driver.findElement(By.linkText("x")).click();
driver.findElement(By.cssSelector("#request-types-table a.aui-restfultable-delete-small").click();

Any suggestions? Thank you.

1
  • Have you tried switching to alert ?? Alert alert = driver.switchTo().alert(); alert.accept(); Commented Jul 21, 2016 at 4:14

2 Answers 2

1

try below

driver.findElement(By.cssSelector("a.aui-button.aui-button-link.aui-restfultable-delete.aui-restfultable-delete-small").click();
Sign up to request clarification or add additional context in comments.

3 Comments

Thank You! I can see that it is working because it is highlighting but the first x is disabled, how do I get Selenium to move to second x without moving to the next step altogether?
you can use findElements which returns a list of matching elements and get the second one
For example, there are 5 x's in total, the first one is disabled hence when I use the above code I displayed the option is "Disabled", how do I move to the next x instead of moving on to something else?
1

My guess is that the locator below is unique on the page.

driver.findElement(By.cssSelector("a[original-title='Delete resolved']")).click();

Comments

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.