2017-10-21 94 views
0

J'essaie de cliquer sur le menu déroulant de mon application Web, puis de cliquer sur les sous-éléments qui se trouvent dans DIV. Voici le code que j'essaie d'exécuter.org.openqa.selenium.ElementNotInteractableException: Impossible de cliquer sur l'élément

WebElement mnuElement; 
WebElement submnuElement; 

mnuElement = driver.findElement(By.id("CollectorsTab")); 
// Thread.sleep(3000); 

submnuElement = driver.findElement(By.id("IdentityCollectorsTab")); 

Actions builder = new Actions(driver); 
// Move cursor to the Main Menu Element 
builder.moveToElement(mnuElement).perform(); 
// Pause 2 Seconds for submenu to be displayed 
TimeUnit.SECONDS.sleep(2); //Pause 2 seconds 
// Clicking on the Hidden submnuElement 
submnuElement.click(); 

J'ai lu dans quelques-unes des questions qui d'essayer plus attendre aussi je l'ai essayé, mais j'obtiens tout le temps ci-dessous erreur.

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: Cannot click on element 
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:40.131Z' 
System info: host: 'UKPC31732', ip: '172.31.1.202', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144' 
Driver info: org.openqa.selenium.ie.InternetExplorerDriver 
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:1486/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, browserName=internet explorer, pageLoadStrategy=normal, javascriptEnabled=true, platformName=WINDOWS, setWindowRect=true, platform=WINDOWS}] 
Session ID: e6579c86-fd88-4ce0-8820-1d4c644ba7ee 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) 
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586) 
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279) 
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83) 
    at FlowIAM.main(FlowIAM.java:67) 

Répondre

0

Essayez ci-dessous le code de cliquer sur le sous-menu

WebElement mnuElement; 
WebElement submnuElement; 

mnuElement = driver.findElement(By.id("CollectorsTab")); 
submnuElement = driver.findElement(By.id("IdentityCollectorsTab")); 

Actions action = new Actions(driver); 
action.moveToElement(mnuElement).clickAndHold(submnuElement).click().build().perform(); 

Parfois, nous avons besoin de cliquer et de maintenir et d'avoir à cliquer sur le sous-menu. J'espère que ce code aide

+0

Merci Cela fonctionne aussi! C'est similaire que j'essayais juste. – user2592029