2014-12-28 2 views
0

PHPUnit (3.7.38), Selenium2 (2.43.1-standalone) 및 Firefox (34.0)를 사용하여 사이트를 테스트하고 있으며 Selenium과 관련하여 간헐적 인 문제가 계속 발생하고 있습니다. 페이지에서 태그를 찾을 수 있습니다. 오류의 스크린 샷을 찍으면 태그와 콘텐츠가 있고 페이지가 완전히로드 된 것처럼 보입니다. 내가로드하려고하는 태그에 대해 AJAX를 사용하면 문제가 발생할 수 있습니다.PHPUnit Selenium2 테스트에서 태그를 찾을 수 없습니다.

약 50 %의 시간과 몇 가지 특정 테스트에서 발생하는 것으로 보입니다. 또한, 테스트의 특정 행을 향해 끌리는 것처럼 보이지만 문제가되는 행을 주석 처리하면 일반적으로 행이 바뀝니다. 테스트 사이에 몇 분 정도 기다리면 오류없이 실행되는 것처럼 보이지만 그 이외의 테스트에서는 영향을주지 않는 것을 찾을 수 없습니다.

특정 예외입니다 :

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Unable to locate element: {"method":"tag name","selector":"h2"}

셀레늄 추적 :

22:32:34.544 INFO - Executing: [find element: By.tagName: h2]) 
22:32:35.704 WARN - Exception thrown org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"tag name","selector":"h2"} 
Command duration or timeout: 220 milliseconds 
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html 
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33' 
System info: host: 'andrew-xubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.7.0_65' 
Session ID: e842f08c-176e-4361-859b-8fc8e67b8d5c 
Driver info: org.openqa.selenium.firefox.FirefoxDriver 
Capabilities [{platform=LINUX, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=34.0}] 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByTagName(RemoteWebDriver.java:417) 
    at org.openqa.selenium.By$ByTagName.findElement(By.java:330) 
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344) 
    at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101) 
    at com.sun.proxy.$Proxy1.findElement(Unknown Source) 
    at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:184) 
    at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:47) 
    at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"tag name","selector":"h2"} 
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html 
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33' 
System info: host: 'andrew-xubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.7.0_65' 
Driver info: driver.version: unknown 
    at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///tmp /anonymous8627931668853884881webdriver-profile/extensions/[email protected]/components/driver-component.js:9618:26) 
    at <anonymous class>.FirefoxDriver.prototype.findElement(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/[email protected]/components/driver-component.js:9627:3) 
    at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/[email protected]/components/command-processor.js:11612:16) 
    at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/[email protected]/components/command-processor.js:11617:7) 
    at <anonymous class>.DelayedCommand.prototype.execute/<(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/[email protected]/components/command-processor.js:11559:5) 
22:32:35.706 WARN - Exception: Unable to locate element: {"method":"tag name","selector":"h2"} 
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html 
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33' 
System info: host: 'andrew-xubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.7.0_65' 
Driver info: driver.version: unknown` 

답변

0

은 셀레늄 요소가 고정 찾기 위해 대기하는 시간 흐름이 완만 것 같은데. 이 코드를 각 테스트에 추가하면 Selenium이 페이지를로드 할 때마다 시간이 증가합니다.

function setUpPage() { 
     $this->timeouts()->implicitWait (3000); 
} 
관련 문제