0

Unable to Click a link using Selenium - Webdriver: Chrome:Win7

Following is the code when i inspect the button:

a id="continue_button" disabled="false" class="button button-large ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" href="#" role="button" aria-disabled="false">

span class="ui-button-text"> span class="button-content">Continue

I have tried the following ways and nothing works:

driver.findElement(By.xpath("//*[@id='continue_button']")).click();
driver.findElement(By.xpath("//a[contains(..,'Continue')]")).click();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.querySelector(\"a[id$='continue_button']\").click()");
1
  • wait for the button try first in debug and then try to click driver.verify().verifyElementPresent(by) Commented Dec 17, 2013 at 8:25

5 Answers 5

1

Maybe the link is partially hidden in DOM. You can try clicking hidden (or partially hidden) elements using the code snippet below.

WebElement element = driver.findElement(By.xpath("//a[@id='continue_button']));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", element);
Sign up to request clarification or add additional context in comments.

Comments

0
options=driver.find_elements_by_class_name("button-content")
for i in options:
    if(i.text=="Continue"):
        i.click()

The above code is in python.Try the above code by translating into java and i hope it will work perfect... any queries let me know.

1 Comment

If you're wanting more than one element, you'd need to use .find_elements_by_class_name() for a list to iterate over like presented here.
0

you can try this,

new WebDriverWait(driver,60).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#continue_button span.button-content"))).click();

The above code will wait for 60 secs for the elements visibilty, if located ,element will be clicked else an exception will be thrown.

Comments

0
if(driver.getTitle().contains("Error"))
    driver.navigate().to("javascript:document.getElementById('overridelink').click()");

1 Comment

It's better if you explain why your code solves the problem. See How to Answer.
-1

hey do check whether the button lies in a frame or not..

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.