Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...