Reputation: 55
I am using Google Chrome as webdriver.
The Sign Up button code is:
<button type="submit" class="signupbtn btn_full btn btn-action btn-block btn-lg">
<span class="ink animate" style="height: 488px; width: 488px; top: -215px; left: -118px;"></span>
<i class="fa fa-check-square-o"></i>
Sign Up
</button>
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (681, 658)
driver.findElement(By.xpath("//*@id='headersignupform']/div[9]/button")).click();
However, it is not executing the script and is throwing the above error. As you can see, in the console it is locating the button with my code in the console.
Upvotes: 1
Views: 3822
Reputation: 370
You could use an action class for the same:
WebElement element = driver.findElement(By.xpath("//*[@id='headersignupform']/div[9]/button"));
Actions actions = new Actions(driver);
actions.moveToElement(element).click().perform();
The second thing is it's always advisable to use an exact tag instead of *[@id =""].
Upvotes: 0
Reputation: 193088
It seems the Sign Up button has an overlay. So to interact directly with the Sign Up button, we need to use the help of JavascriptExecutor as follows:
WebElement button = driver.findElement(By.xpath("//button[@class='signupbtn btn_full btn btn-action btn-block btn-lg']"));
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].click();", button);
Upvotes: 2
Reputation: 17553
You need to use focus or scroll to that element. You also might have to use an explicit wait.
WebElement element = driver.findElement(By.xpath("//*@id='headersignupform']/div[9]/button"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.perform();
If it still does not work, use JavascriptExecutor
:
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
Upvotes: 2