2017-08-22 185 views
-1

我有一個自動化的硒腳本在一個maven項目中用於執行某些功能。問題是當我使用Testng的eclipse觸發它時, 它失敗並且eclipse引發了一些我無法重新使用的錯誤。 我附帶了錯誤跟蹤。 org.openqa.selenium.TimeoutException: Expected condition failed: waiting for presence of element located by: By.xpath: //*[text()='com.prism.soap.sftp.msg.mping.iflow']/../../../..//div[@class='OneByOne sapMGTHdrContent'] (tried for 25 second(s) with 2 SECONDS interval) at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:264) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:232) at com.webui.Others.webui.tooling.Prism_Master_Class.webdriver_wait(Prism_Master_Class.java:47) at com.webui.Monitor.automation.Prism_Selenium_Monitor_Tab.prism_monitor_messageProcessing(Prism_Selenium_Monitor_Tab.java:732) at com.webui.Others.webui.tooling.Message_Processing_Vaidation.messageProcessingCheck(Message_Processing_Vaidation.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:230) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76) Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.xpath: //*[text()='com.prism.soap.sftp.msg.mping.iflow']/../../../..//div[@class='OneByOne sapMGTHdrContent'] For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'INLN50942827A', ip: '10.53.219.90', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131' Driver info: driver.version: unknown at org.openqa.selenium.support.ui.ExpectedConditions.lambda$findElement$0(ExpectedConditions.java:883) at java.util.Optional.orElseThrow(Unknown Source) at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:882) at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:44) at org.openqa.selenium.support.ui.ExpectedConditions$6.apply(ExpectedConditions.java:183) at org.openqa.selenium.support.ui.ExpectedConditions$6.apply(ExpectedConditions.java:180) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:209) ... 27 more 運行硒腳本時出錯

+0

你錯誤讀取'NoSuchElementException'這是findElement無法找到您正在尋找的實際WebElement時可能的。 – nullpointer

回答

0

您的錯誤似乎是由於使用您的定位器代碼找不到元素而引起的,因此稱爲NoSuchElementException。再次檢查您的代碼。