2016-11-23 38 views
0

我在Eclipse「元素不是在點點擊」,只有瀏覽器,任何等待不起作用

org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (288, 196). Other element would receive the click: <div style="display: block; opacity: 0.00664228; z-index: 3001; position: absolute; cursor: wait; background-color: white; width: 1536px; height: 771px; top: 0px; left: 0px; border-radius: 0px;" dojoattachpoint="_underlayNode"></div> 
     (Session info: chrome=54.0.2840.99) 
     (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) 
    Command duration or timeout: 38 milliseconds 
    Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40' 
    System info: host: 'ADMINIB-JIGAGHP', ip: '9.164.178.163', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', 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.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed), userDataDir=C:\Users\IBM_AD~1\AppData\Local\Temp\scoped_dir10616_4624}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.99, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] 
    Session ID: 6abd80443ba6dbea601d80248a4c8485 
     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.ErrorHandler.createThrowable(ErrorHandler.java:206) 
     at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
     at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
     at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327) 
     at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85) 
     at Tasks.CategoryHandler.editCategory(CategoryHandler.java:152) 
     at TestCases.LogInEditCategory.editCategory(LogInEditCategory.java:21) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85) 
     at org.testng.internal.Invoker.invokeMethod(Invoker.java:639) 
     at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816) 
     at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124) 
     at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) 
     at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108) 
     at org.testng.TestRunner.privateRun(TestRunner.java:774) 
     at org.testng.TestRunner.run(TestRunner.java:624) 
     at org.testng.SuiteRunner.runTest(SuiteRunner.java:359) 
     at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354) 
     at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312) 
     at org.testng.SuiteRunner.run(SuiteRunner.java:261) 
     at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
     at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
     at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215) 
     at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) 
     at org.testng.TestNG.run(TestNG.java:1048) 
     at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) 
     at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236) 
     at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81) 

我使用硒2.5它適用於Firefox,但無法在Chrome有這個錯誤。我已經嘗試了很多選擇,但沒有一個可行。

  WebDriverWait wait = new WebDriverWait(driver, 120); 

      WebElement element = wait.until(ExpectedConditions 
        .elementToBeClickable(By.xpath(".//*[@id='bg_widget_AssetListItem_0']/div[1]/input"))); 
      //driver.manage().timeouts().pageLoadTimeout(120,TimeUnit.SECONDS); 
      // driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); 
      //Thread.sleep(2000); 

      driver.findElement(By.xpath(".//*[@id='bg_widget_AssetListItem_0']/div[1]/input")).click(); 

只有Thread.sleep(2000)適合我,但我知道這是不好的選擇。 那麼,我能做些什麼來處理超時或等待呢?

+0

嘗試'element.click()'而不是用'司機再次找到元素。 findElement()' –

回答

0

我想你的網頁加載過程中會出現一個模式窗口,如this。 Webdriver無法識別它,並單擊該按鈕,此時該按鈕實際上不可點擊。這似乎是衆所周知的chromedriver問題。

正如你所提到的,你可以使用武力的等待,像Thread.sleep(2000),還是要等到模式窗口disappeared

new WebDriverWait(driver, 10).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath('//div[@style="display: block; opacity: 0.00664228; z-index: 3001; position: absolute; cursor: wait; background-color: white; width: 1536px; height: 771px; top: 0px; left: 0px; border-radius: 0px;"]')))); 
+0

它對我很好!但我真的不知道這是什麼xpath: ''// div [@ style =「display:block; opacity:0.00664228; z-index:3001; position:absolute; cursor:wait; background-color:white ; width:1536px; height:771px; top:0px; left:0px; border-radius:0px;「]'' 你如何得到它? – robmax

+0

從你提供的日誌 – Andersson

相關問題