Unable to click on 'Add' button in GUI (Error: Other element would receive the click)

∥☆過路亽.° 提交于 2019-12-13 08:37:59

问题


I am trying to click on 'Add' button but I am getting the following error message:

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown 
error: Element <img src="theme/catalogSiemens/images/btn/btnBackCatalog.png" 
alt="Zurück" title="Zurück"> is not clickable at point (53, 57). Other 
element would receive the click: <div id="updateIndicator" 
class="waitVisible"></div>
(Session info: chrome=58.0.3029.110)
(Driver info: chromedriver=2.29.461591 
(62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.10586 
x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 581 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'P3B-BQHT7R1', ip: '10.222.132.78', os.name: 'Windows 
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, 
mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=
{chromedriverVersion=2.29.461591 (62ebf098771772160f391d75e589dc567915b233)

My code is:

driver.findElement(By.linkText("CMT Desigo CC")).click();
    driver.findElement(By.linkText("Basis")).click();
    driver.findElement(By.xpath("//img[@alt='In den Einkaufswagen 
legen']")).click();
    System.out.println("Item 1 added");
driver.findElement(By.xpath("//img[@alt='Zurück']")).click();

HTML is:

<a onclick="      if (document.referrer && 
document.referrer.indexOf('cameleonUI') > -1){if 
(Prototype.BrowserFeatures.isAndroid) {history.back();} else {if 
(document.referrer.startsWith(document.baseURI)) 
{location.href=document.referrer; } else {/* do nothing, too risky 
*/}}}else{goBack('close.do?S_moduleContextId=cat');}; return false;
                     "
                    id="tile282_0"
                    actionName="BACK"
                        href="#"
                        target="_blank"
                    class=""  >  <img 
src="theme/catalogSiemens/images/btn/btnBackCatalog.png" alt="Zurück" 
title="Zurück" /> </a>

Any suggestions will be appreciated. Also let me know if more information is needed. Thanks in advance.


回答1:


I think previous solution solved the problem but in order not to have this behavior again randomly you will have to increase the wait time a little bit and re run it more than one time to be sure that the wait time is enough as the page elements loading will not be the same each time you run your code

You can do so by increasing the 10 to be 15 or 20 seconds:

 WebDriverWait wait2 = new WebDriverWait(driver, 20);
    WebElement element2 = wait2.until(ExpectedConditions.elementToBeClickable(By.xpath("//img[@alt='Zurück']")));
    element2.click();



回答2:


From the exception you got I can understand that your page is loading or some div is covering up your div element. To avoid that, you can wait until your page loads(if some loader appears while loading page use fluent wait for that loader element until that element is invisible) or at least cases some application loads more than once at a time. So for that case place Thread sleep. Let me know if there is any issue.




回答3:


Here is the Answer to your Question:

It is pretty much clear from the error stack trace that element is present in the DOM but not clickable. It means there is a overlay. So to over come this situation you must be using ExplicitWait as follows:

    WebDriverWait wait2 = new WebDriverWait(driver, 10);
    WebElement element2 = wait2.until(ExpectedConditions.elementToBeClickable(By.xpath("//img[@alt='Zurück']")));
    element2.click();

Let me know if this Answers your Question.



来源:https://stackoverflow.com/questions/44016214/unable-to-click-on-add-button-in-gui-error-other-element-would-receive-the-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!