2017-12-26 28 views
-1

코드 :I getException "주"org.openqa.selenium.ElementNotInteractableException

WebElement betting = driver.findElement(By.id("flex-menu")); 
     List<WebElement> hallo = betting.findElements(By.xpath("//*[@id='flex-menu']//ul//li//a")); 

      System.out.println(hallo.get(0).getText()); 

      hallo.get(0).click(); 

오류 마사지 : 스레드

예외 "주" org.openqa.selenium.ElementNotInteractableException :

세션 ID : sun.reflect.NativeConstructorAccessorImpl.newInstance0 (원시 메소드)에 4bfaaf77-6275-4ffc-a8d7-b24b70f3acca 0에서sun.reflect.NativeConstructorAccessorImpl.newInstance sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance에서 에서 (NativeConstructorAccessorImpl.java:62) (Constructor.java:422) 에서 org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:122)에서 (W3CHttpResponseCodec.java:187) 에서 조직도 .openqa.selenium.remote.http.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute org.openqa.selenium.remote.RemoteWebDriver.execute에서 org.openqa.selenium.remote.service.DriverCommandExecutor.execute (DriverCommandExecutor.java:83)에서 (HttpCommandExecutor.java:164) (RemoteWebDriver.java:601 org.openqa.selenium.remote.RemoteWebElement.execute (RemoteWebElement.java:279 AT) ) org.openqa.selenium.remote.RemoteWebElement.click (RemoteWebElement.java:83 AT)에서 Aufgabe1.Main.main (Main.java:41)

해당 코드가 잘못되었습니다. 나는 클릭을 할 수 없지만 요소를 발견했다.

+0

[Selenium WebDriver의 가능한 복제본은 "스레드의 예외"main "org.openqa.selenium.ElementNotInteractableException : 요소가 표시되지 않습니다"오류 발생 (https://stackoverflow.com/questions/44690971/selenium-webdriver-throws -exception-in-thread-main-org-openqa-selenium-elemen) – DebanjanB

답변

1

두 가지 이유 때문일 수 있습니다.

1) 버튼 요소는 표시되지만 클릭 할 수는 없습니다. 그 경우 대기 조건을 사용하십시오.

WebDriverWait myWaitVar = new WebDriverWait(driver,20); 
WebElement el = myWaitVar.until(ExpectedConditions.elementToBeClickable(betting.findElements(By.xpath("//*[@id='flex-menu']//ul//li//a")).get(0))); 
el.click(); 

2) 요소가 숨겨져있는 경우/다른 요소에 의해 중복 In Selenium Webdriver, ExpectedCondition.elementToBeClickable is not waiting until the progress bar disappears

0

에 JavascriptExecutor

WebDriverWait myWaitVar = new WebDriverWait(driver,20); 
    WebElement el = myWaitVar.until(ExpectedConditions.elementToBeClickable(betting.findElements(By.xpath("//*[@id='flex-menu']//ul//li//a")).get(0))); 
((JavascriptExecutor)driver).executeScript("arguments[0].click()", el); 

더 많은 정보를 사용할 수를 사용하는 것이 당신이하려고하는 요소가 가리는 때문에 될 수있다/암시 적 대기 조건이 필요합니다. .enable() 함수를 사용하여 암시 적 - 명시 적 대기 조건을 구현 한 다음 .click() 함수를 사용하려고합니다.