WebDriverException Element is not clickable in Selenium [duplicate] - selenium

This question already has answers here:
Element MyElement is not clickable at point (x, y)... Other element would receive the click
(5 answers)
Closed 4 years ago.
Here is the error message:
org.openqa.selenium.WebDriverException: unknown error: Element <div class="col-md-2 col-sm-2 hidden-xs days" id="lblday3">...</div> is not clickable at point (799, 308). Other element would receive the click: <div class="modal-body text-center">...</div>
(Session info: chrome=69.0.3497.100)
Hi everyone, the above exception was thrown in my ThankYou page in my project. I've tried to change the wait time but it also doesn't work. Below is the method I used.
public void Clickthankyou() throws InterruptedException
{
if(driver.findElement(By.xpath("//*[#id='id_appoint']/h2")).isDisplayed())
{
WebDriverWait wait = new WebDriverWait(driver, 6);
WebElement elem =wait.until(ExpectedConditions.elementToBeClickable(Dateselect));
if(elem.isDisplayed())
{
elem.click();
}
Thread.sleep(2000);
driver.findElement(Clickbook).click();
}
else
{
driver.navigate().back();
}

The basic reason of this exception is due to ViewPort of Browser window which is seen by the user.
You need to scroll to specific element then click on it.
Key thing is element is not visible so not eligible for clicking.
ok use this code for do the fix using JavascriptExecutor ,
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeAsyncScript('arguments[0].scrollIntoView(true)', driver.findElement(By.xpath("//*[#id='id_appoint']/h2")))
js.executeAsyncScript('window.scrollBy(0,-150)')
or you can also do same using Actions class.
new Actions(driver).moveToElement(driver.findElement(By.xpath("//*[#id='id_appoint']/h2"))).click().perform();
Possible duplicate of Debugging "Element is not clickable at point" error

Related

ElementClickInterceptedException Selenium unable to click button Python [duplicate]

This question already has answers here:
Element MyElement is not clickable at point (x, y)... Other element would receive the click
(5 answers)
Closed 2 years ago.
I'm writing a selenium test that clicks on a specific button on a page. There are no other buttons present on the page but it seems like it's been obstructed so the codes unable to find it.
I've tried to maximum the page in the hope it can find the button but it's unable to do so
My code
driver.maximize_window()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[#id='save' and #name='save'][#value='View Report']"))).click()
copy of the element
<input type="submit" value="View Report" id="save" name="save" data-reportid="108">
Error
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (1750, 770). Other element would receive the click: ...
(Session info: chrome=83.0.4103.116)
I think that another element may be overlapped your element, and you should wait for the invisibility of this layer. The layer can be a loading frame or anything else.
WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.CSS_SELECTOR, "selector_for_ovelapped_layer")))
and then click the element you needed
Also, you can use Actions:
element = driver.find_element_by_xpath("//input[#id='save' and #name='save'][#value='View Report']")
webdriver.ActionChains(driver).move_to_element(element).click(element).perform()
And you can do this with JSExecutor:
element = driver.find_element_by_xpath("//input[#id='save' and #name='save'][#value='View Report']")
driver.execute_script("arguments[0].click();", element)

org.openqa.selenium.ElementClickInterceptedException [duplicate]

This question already has answers here:
ElementClickInterceptedException: Message: element click intercepted: Element <label> is not clickable with Selenium and Python
(2 answers)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable with Selenium and Python
(11 answers)
Closed 2 years ago.
Hi I am trying to write a piece of selenium code for the login page of: https://www.phptravels.net/admin.
I ab able to find the xpath for log in button but when the code is triggered I get this exception:
org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element ... is not clickable at point (640, 532). Other element would receive the click: ...
The code which I have written is:
public class pageObjectRepo {
WebDriver driver;
String mail="admin#phptravels.com";
String pass="demoadmin";
public pageObjectRepo(WebDriver driver)
{
this.driver=driver;
}
By email = By.xpath("(//*[#name='email'])[1]");
By pwd = By.xpath("(//*[#name='password'])[1]");
By loginbtn= By.xpath("//button[#type='submit']");
public void login() throws InterruptedException {
driver.findElement(email).sendKeys(mail);
Thread.sleep(1000);
driver.findElement(pwd).sendKeys(pass);
driver.manage().window().maximize();
Thread.sleep(5000);
driver.findElement(loginbtn).click();
}
login method is called in the actual test class.
I would try using the name locator instead of xpath which looks wrong.
By email = By.name("email]");
Try the same for password as well.
Do not use Thread. Sleep in order to wait for your web elements. Instead, use explicit wait. Moreover before clicking on the button check if the button is displayed and is enabled and then perform the click.

Element is not clickable at point. Other element would receive the click [duplicate]

This question already has answers here:
Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click
(9 answers)
Closed 3 years ago.
How can I bypass this and select the value I need?
behat #selenium2 #drupal7
When I select "male" from "profile_additional[field_gender][und]"
/**
* #When /^I check the "([^"]*)" radio button$/
*/
public function iCheckTheRadioButton($labelText)
{
foreach ($this->getMainContext()->getSession()->getPage()->findAll('css', 'label') as $label) {
if ($labelText === $label->getText() && $label->has('css', 'input[type="radio"]')) {
$this->getMainContext()->fillField($label->find('css', 'input[type="radio"]')->getAttribute('name'), $label->find('css', 'input[type="radio"]')->getAttribute('value'));
return;
}
}
throw new \Exception('Radio button not found');
}
Drupal\DrupalExtension\Context\MinkContext::selectOption()
unknown error: Element is not clickable at point (547, 470). Other
element would receive the click: ...
(Session info: chrome=74.0.3729.131)
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT
10.0.17763 x86_64) (WebDriver\Exception\UnknownError)
The element you are trying to interact with is hidden beneath some other element. You can try using Actions to first move to your element, then try to interact with it. Now I am not an expert in PHP and I think this is the language you are using, the action should look something like this:
$action = new WebDriverActions($this->driver);
$action->moveToElement($element)->click()->perform();
If you know what element is causing this behaviour, then you can also try waiting for it to be gone, usually done via waiting for style attribute to contain none as in display:none
Better to use scroll to web element using javascript executor
JavascriptExecutor jse = (javascriptExecutor)driver;
jse.executeScript("arguments[0].scrollIntoView();"element)
This will resolve your issue

Selenium webdriver wait doesn't seem to work in case of overlay

There is an overlay ( a grey color translucent screen ) that comes up when ever one clicks Login button and it stays for few seconds. Because of this, selenium web driver isn't able to find the elements as this overlay kinds of hides them for a while or at least that is what looks to me. How can I handle this? I don't find Thread.sleep to be an efficient way here.
I tried -
public void login(){
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.invisibilityOfElementLocated((By.id("ajax-overlay"))));
wait.until(ExpectedConditions.elementToBeClickable((By.id("okbutton))));
driver.findElement(By.id("username)).sendKeys("admin");
driver.findElement(By.id("password")).sendKeys("admin123");
driver.findElement(By.id("okbutton")).click();
wait.until(ExpectedConditions.invisibilityOfElementLocated((By.id("ajax-overlay"))));
}
but nothing seems to work and I still get error -
org.openqa.selenium.WebDriverException: unknown error: Element <button id="loginDialog:okButton" name="loginDialog:okButton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-panel-titlebar-icon synchronous" onclick="PrimeFaces.ab({source:'loginDialog:okButton',process:'loginDialog:okButton loginDialog:username loginDialog:password loginDialog:okButton',update:'startingCashFocus loginDialog:dialogFocus loginDialog:lblPassword loginDialog:lblUsername loginDialog:messages',oncomplete:function(xhr,status,args){handleLoginAttempt(xhr, status, args, loginWidget, null); ;}});return false;" tabindex="1" type="submit" role="button" aria-disabled="false">...</button> is not clickable at point (931, 250). Other element would receive the click: <div id="ajax-overlay" class="ui-blockui ui-widget-overlay ui-helper-hidden eternal" style="display: block;"></div>
Also, there is no way to find out the overlay id and thankfully, selenium gave it in its error details.
Try to click element with one of the following method, which will solve this Exception :
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.id('okbutton'))).click().perform();
OR
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", driver.findElement(By.id('okbutton')));

com.thoughtworks.selenium.SeleniumException: unknown error: Element is not clickable

Environment
Chrome : Version 39.0.2171.95
Chrome Driver : 2.13 (Latest)
Selenium WebDriver
I need to enter key in textbox and then click on enter button. Script is working fine in IE and FF. But when it comes to chrome I find an error
com.thoughtworks.selenium.SeleniumException: unknown error: Element is not clickable at point (221, 191). Other element would receive the click:
Some solutions which I saw is using
((JavascriptExecutor) driver).executeScript("window.scrollTo(0,\"+elementToClick.getLocation().y+\")");
but it dint work out for me.
Thanks in advance
Try waiting for the element to be clickable and then clicking on it.
You can use the below code for that:
//Wait for 20 seconds to detect that the element is clickable, and then clicking on it
try{
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//xpath of the Enter button")));
element.click();
}catch(Throwable e){
System.err.println("Error while waiting for the element to be clickable: "+e.getMessage());
}