gpt4 book ai didi

java - 在 Play Framework 中将 cucumber 与 selenium webdriver 一起使用时调试日志

转载 作者:搜寻专家 更新时间:2023-11-01 03:01:06 24 4
gpt4 key购买 nike

我一直在尝试将 cucumber-jvm 与 selenium webdriver (firefox) 集成,但是在我让它运行我的测试之后,我认为我看到了很多来自 selenium 的调试日志。

这是我目前的结构。

enter image description here

添加了我的 build.sbt 依赖项:

  "info.cukes" % "cucumber-java" % "1.2.4",
"info.cukes" % "cucumber-junit" % "1.2.4",
"info.cukes" % "cucumber-picocontainer" % "1.2.4",
"org.seleniumhq.selenium" % "selenium-java" % "2.48.2"

软件部门:

Centos 6 64bit.
Firefox "Mozilla Firefox 31.3.0"
Java java version "1.8.0_45" (build 1.8.0_45-b13)

FirefoxDriver 实例化:

@Before
public void setUp() throws Exception {
if (driver == null) {
driver = new FirefoxDriver();
driver.navigate().to(base_url);
driver.manage().deleteAllCookies();
}
}

Junit 亚军:

@RunWith(Cucumber.class)
@CucumberOptions(
features="test/acceptance/features",
glue={"context"},
plugin={"html:cucumberReport"}
)
public class CucumberRunnerTest {
}

我如何运行测试:

./activator clean compile test

我得到的日志类型:

16:11:54.212 [Forwarding newSession on session null to remote] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
16:11:54.213 [Forwarding newSession on session null to remote] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
16:11:54.213 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://127.0.0.1:7056][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
16:11:54.213 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 16][route: {}->http://127.0.0.1:7056][total kept alive: 0; route allocated: 1 of 2000; total allocated: 1 of 2000]
16:11:54.213 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://127.0.0.1:7056
16:11:54.213 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to /127.0.0.1:7056
16:11:54.214 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 127.0.0.1:39264<->127.0.0.1:7056
16:11:54.214 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-16: set socket timeout to 10800000
16:11:54.214 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request POST /hub/session HTTP/1.1
16:11:54.214 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
16:11:54.214 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 >> POST /hub/session HTTP/1.1
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 >> Content-Type: application/json; charset=utf-8
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 >> Content-Length: 105
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 >> Host: 127.0.0.1:7056
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 >> Connection: Keep-Alive
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 >> User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_45)
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 >> Accept-Encoding: gzip,deflate
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "POST /hub/session HTTP/1.1[\r][\n]"
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "Content-Type: application/json; charset=utf-8[\r][\n]"
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "Content-Length: 105[\r][\n]"
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "Host: 127.0.0.1:7056[\r][\n]"
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "Connection: Keep-Alive[\r][\n]"
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_45)[\r][\n]"
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "Accept-Encoding: gzip,deflate[\r][\n]"
16:11:54.215 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "[\r][\n]"
16:11:54.216 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 >> "{"desiredCapabilities":{"browserName":"firefox","version":"","platform":"ANY"},"requiredCapabilities":{}}"
16:11:54.307 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "HTTP/1.1 200 OK[\r][\n]"
16:11:54.307 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "content-type: application/json; charset=UTF-8[\r][\n]"
16:11:54.307 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "connection: close[\r][\n]"
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "content-length: 421[\r][\n]"
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "server: httpd.js[\r][\n]"
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "date: Thu, 10 Dec 2015 16:11:54 GMT[\r][\n]"
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "[\r][\n]"
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 << HTTP/1.1 200 OK
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 << content-type: application/json; charset=UTF-8
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 << connection: close
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 << content-length: 421
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 << server: httpd.js
16:11:54.308 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-16 << date: Thu, 10 Dec 2015 16:11:54 GMT
16:11:54.310 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-16 << "{"name":"newSession","sessionId":"d1aa222a-0c82-46a6-a0dd-80942dc13274","status":0,"value":{"cssSelectorsEnabled":true,"browserName":"firefox","handlesAlerts":true,"javascriptEnabled":true,"nativeEvents":false,"platform":"Linux","rotatable":false,"takesScreenshot":true,"version":"31.3.0","webStorageEnabled":true,"applicationCacheEnabled":true,"databaseEnabled":true,"locationContextEnabled":true,"acceptSslCerts":true}}"
16:11:54.310 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-16: Close connection
16:11:54.310 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Connection discarded
16:11:54.310 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 16][route: {}->http://127.0.0.1:7056][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]

我是 jvm-cucumber 的新手,如果有人能帮助我,我会很高兴:)如果我有任何新消息,我会及时通知您。

更新:

我不知道为什么“Before”和“Given”子句不打印任何调试日志。任何其他的。

最佳答案

对于我的 Cucumber 和 webdriver 的 Maven 项目,解决方案是将一个文件添加到“/resources/logback.xml”,其内容如下。

所以它应该能够为游戏框架做同样的事情。使用以下内容创建“conf/resources/logback.xml”:

<configuration debug="false">
<!-- definition of appender STDOUT -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender>

<root level="ERROR">
<!-- appender referenced after it is defined -->
<appender-ref ref="STDOUT"/>
</root>
</configuration>

(来源:https://stackoverflow.com/a/8936580/2827420)

关于java - 在 Play Framework 中将 cucumber 与 selenium webdriver 一起使用时调试日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34205914/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com