Selenium 使用子项目和集成测试
我在play项目中执行最小集成测试,如下所示:Selenium 使用子项目和集成测试,selenium,playframework,playframework-2.0,integration-testing,fluent,Selenium,Playframework,Playframework 2.0,Integration Testing,Fluent,我在play项目中执行最小集成测试,如下所示: @测试 公开无效测试(){ Logger.info(“启动集成测试”); 正在运行(testServer(3333,fakeApplication(inMemoryDatabase())),FIREFOX,新回调(){ 公共void调用(TestBrowser浏览器){ Logger.info(“调用测试浏览器”); browser.goTo(“http://localhost:3333/linklist"); assertThat(browser
@测试
公开无效测试(){
Logger.info(“启动集成测试”);
正在运行(testServer(3333,fakeApplication(inMemoryDatabase())),FIREFOX,新回调(){
公共void调用(TestBrowser浏览器){
Logger.info(“调用测试浏览器”);
browser.goTo(“http://localhost:3333/linklist");
assertThat(browser.pageSource())。包含(“我的页面中的某些字符串”);
}
});
}
我已经将项目分为多个子项目(main->frontend->common
和main->backend->common
)。集成测试在主项目中运行
已编辑
在测试运行中,直到browser.goTo(“http://localhost:3333/linklist");代码>并在45秒后停止
Firefox打开,什么也没发生。但我可以把自己的网址http://localhost:3333/linklist
然后像这样转到页面
看起来浏览器
实例与打开的实例不同
此处显示错误消息:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
*** LOG addons.manager: Application has been upgraded
*** LOG addons.xpi: startup
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi-utils: Opening database
*** LOG addons.xpi-utils: Creating database schema
*** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
*** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
*** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
*** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
*** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
*** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
*** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
*** LOG addons.xpi: Updating database with changes to installed add-ons
*** LOG addons.xpi-utils: Updating add-on states
*** LOG addons.xpi-utils: Writing add-ons list
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi-utils: shutdown
*** LOG addons.xpi-utils: Database closed
*** LOG addons.xpi: startup
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:109)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
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:525)
at java.lang.Class.newInstance0(Class.java:374)
at java.lang.Class.newInstance(Class.java:327)
at play.api.test.WebDriverFactory$.apply(Selenium.scala:95)
at play.api.test.WebDriverFactory.apply(Selenium.scala)
at play.test.TestBrowser.<init>(TestBrowser.java:24)
at play.test.Helpers.testBrowser(Helpers.java:467)
at play.test.Helpers.testBrowser(Helpers.java:459)
at play.test.Helpers.running(Helpers.java:427)
at frontend.IntegrationTest.test(IntegrationTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at com.novocode.junit.JUnitRunner.run(JUnitRunner.java:84)
at sbt.ForkMain$Run.runTests(ForkMain.java:155)
at sbt.ForkMain$Run.run(ForkMain.java:169)
at sbt.ForkMain.main(ForkMain.java:84)
[error] Test frontend.IntegrationTest.test failed: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
[error] *** LOG addons.manager: Application has been upgraded
[error] *** LOG addons.xpi: startup
[error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
[error] *** LOG addons.xpi: checkForChanges
[error] *** LOG addons.xpi-utils: Opening database
[error] *** LOG addons.xpi-utils: Creating database schema
[error] *** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
[error] *** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
[error] *** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
[error] *** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
[error] *** LOG addons.xpi: Updating database with changes to installed add-ons
[error] *** LOG addons.xpi-utils: Updating add-on states
[error] *** LOG addons.xpi-utils: Writing add-ons list
[error] *** LOG addons.manager: shutdown
[error] *** LOG addons.xpi: shutdown
[error] *** LOG addons.xpi-utils: shutdown
[error] *** LOG addons.xpi-utils: Database closed
[error] *** LOG addons.xpi: startup
[error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
[error] *** LOG addons.xpi: checkForChanges
[error] *** LOG addons.xpi: No changes found
[error]
[error] Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'
[error] System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-28-generic', java.version: '1.7.0_21'
[error] Driver info: driver.version: FirefoxDriver
[error] at play.test.Helpers.running(Helpers.java:430)
[error] at frontend.IntegrationTest.test(IntegrationTest.java:27)
[error] ...
[error] Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
[error] *** LOG addons.manager: Application has been upgraded
[error] *** LOG addons.xpi: startup
[error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
[error] *** LOG addons.xpi: checkForChanges
[error] *** LOG addons.xpi-utils: Opening database
[error] *** LOG addons.xpi-utils: Creating database schema
[error] *** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
[error] *** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
[error] *** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
[error] *** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
[error] *** LOG addons.xpi: Updating database with changes to installed add-ons
[error] *** LOG addons.xpi-utils: Updating add-on states
[error] *** LOG addons.xpi-utils: Writing add-ons list
[error] *** LOG addons.manager: shutdown
[error] *** LOG addons.xpi: shutdown
[error] *** LOG addons.xpi-utils: shutdown
[error] *** LOG addons.xpi-utils: Database closed
[error] *** LOG addons.xpi: startup
[error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
[error] *** LOG addons.xpi: checkForChanges
[error] *** LOG addons.xpi: No changes found
[error]
[error] Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'
[error] System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-28-generic', java.version: '1.7.0_21'
[error] Driver info: driver.version: FirefoxDriver
[error] at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:121)
[error] at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)
[error] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:109)
[error] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
[error] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
[error] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
[error] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
[error] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[error] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error] at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
[error] at java.lang.Class.newInstance0(Class.java:374)
[error] at java.lang.Class.newInstance(Class.java:327)
[error] at play.api.test.WebDriverFactory$.apply(Selenium.scala:95)
[error] at play.api.test.WebDriverFactory.apply(Selenium.scala)
[error] at play.test.TestBrowser.<init>(TestBrowser.java:24)
[error] at play.test.Helpers.testBrowser(Helpers.java:467)
[error] at play.test.Helpers.testBrowser(Helpers.java:459)
[error] at play.test.Helpers.running(Helpers.java:427)
[error] ... 32 more
[error] Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
[error] *** LOG addons.manager: Application has been upgraded
[error] *** LOG addons.xpi: startup
[error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
[error] *** LOG addons.xpi: checkForChanges
[error] *** LOG addons.xpi-utils: Opening database
[error] *** LOG addons.xpi-utils: Creating database schema
[error] *** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
[error] *** LOG addons.xpi: New add-on langpack-en-ZA@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
[error] *** LOG addons.xpi: New add-on langpack-en-GB@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on globalmenu@ubuntu.com installed in app-global
[error] *** LOG addons.xpi: New add-on langpack-de@firefox.mozilla.org installed in app-global
[error] *** LOG addons.xpi: New add-on ubufox@ubuntu.com installed in app-system-share
[error] *** LOG addons.xpi: Updating database with changes to installed add-ons
[error] *** LOG addons.xpi-utils: Updating add-on states
[error] *** LOG addons.xpi-utils: Writing add-ons list
[error] *** LOG addons.manager: shutdown
[error] *** LOG addons.xpi: shutdown
[error] *** LOG addons.xpi-utils: shutdown
[error] *** LOG addons.xpi-utils: Database closed
[error] *** LOG addons.xpi: startup
[error] *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous8443545555667681718webdriver-profile/extensions/webdriver-staging
[error] *** LOG addons.xpi: checkForChanges
[error] *** LOG addons.xpi: No changes found
[error] at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)
[error] ... 50 more
[info] frontend.IntegrationTest
[info] x frontend.IntegrationTest.test
[info]
[info]
[info] Total for test frontend.IntegrationTest
[info] Finished in 0.01 seconds
[info] 1 tests, 1 failures, 0 errors
[error] Failed: : Total 1, Failed 1, Errors 0, Passed 0, Skipped 0
[error] Failed tests:
[error] frontend.IntegrationTest
[error] (myapp/test:test-only) Tests unsuccessful
[error] Total time: 58 s, completed May 3, 2013 4:09:49 PM
org.openqa.selenium.firefox.NotConnectedException:45000毫秒后无法连接到端口7055上的主机127.0.0.1。firefox控制台输出:
***LOG addons.manager:应用程序已升级
***LOG addons.xpi:启动
***LOG addons.xpi:忽略名称不是有效加载项ID的文件条目:/tmp/anonymous844354555667681718WebDriver配置文件/扩展名/webdriver暂存
***LOG addons.xpi:检查更改
***LOG addons.xpi-utils:打开数据库
***LOG addons.xpi-utils:创建数据库架构
***LOG addons.xpi:新的加载项fxdriver@googlecode.com安装在应用程序配置文件中
***LOG addons.xpi:新的加载项langpack en-ZA@firefox.mozilla.org安装在全球应用程序中
***LOG addons.xpi:在app global中安装了新的加载项{972ce4c6-7e08-4474-a285-3208198ce6fd}
***LOG addons.xpi:新的加载项langpack en-GB@firefox.mozilla.org安装在全球应用程序中
***LOG addons.xpi:新的加载项globalmenu@ubuntu.com安装在全球应用程序中
***LOG addons.xpi:新的加载项langpack-de@firefox.mozilla.org安装在全球应用程序中
***LOG addons.xpi:新的加载项ubufox@ubuntu.com安装在应用程序系统共享中
***LOG addons.xpi:使用对已安装加载项的更改更新数据库
***LOG addons.xpi-utils:更新加载项状态
***LOG addons.xpi-utils:写入加载项列表
***日志加载项管理器:关闭
***LOG addons.xpi:关闭
***LOG addons.xpi-utils:关闭
***LOG addons.xpi-utils:数据库已关闭
***LOG addons.xpi:启动
***LOG addons.xpi:忽略名称不是有效加载项ID的文件条目:/tmp/anonymous844354555667681718WebDriver配置文件/扩展名/webdriver暂存
***LOG addons.xpi:检查更改
***LOG addons.xpi:未找到任何更改
位于org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)
位于org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)
位于org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:109)
位于org.openqa.selenium.firefox.FirefoxDriver(FirefoxDriver.java:183)
位于org.openqa.selenium.firefox.FirefoxDriver(FirefoxDriver.java:178)
位于org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:174)
位于org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
位于java.lang.reflect.Constructor.newInstance(Constructor.java:525)
位于java.lang.Class.newInstance0(Class.java:374)
位于java.lang.Class.newInstance(Class.java:327)
at play.api.test.WebDriverFactory$.apply(Selenium.scala:95)
at play.api.test.WebDriverFactory.apply(Selenium.scala)
test.TestBrowser.(TestBrowser.java:24)
test.Helpers.testBrowser(Helpers.java:467)
test.Helpers.testBrowser(Helpers.java:459)
运行(Helpers.java:427)
在前端.IntegrationTest.test(IntegrationTest.java:27)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)中
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:601)
位于org.junit.runners.model.FrameworkMethod$1.runReflectVeCall(FrameworkMethod.java:45)
位于org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
位于org.junit.runners.model.FrameworkMethod.invokeeexplosive(FrameworkMethod.java:42)
位于org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
位于org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
位于org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
位于org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
位于org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
位于org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
位于org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
访问org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
位于org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
位于org.junit.runners.ParentRunner.run(ParentRunner.java:300)
位于org.junit.runners.Suite.runChild(Suite.java:128)
位于org.junit.runners.Suite.runChild(Suite.java:24)
在org.junit.runners.Paren