Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debug logs when using cucumber with selenium webdriver in a play framework

I've being trying to integrate cucumber-jvm with selenium webdriver (firefox) but after I made it to run my tests now I'm seeing a lot to debug logs from selenium I think.

Here is my current structure.

enter image description here

My build.sbt dependencies added:

  "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"

Software Deps:

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

FirefoxDriver Instantiation:

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

Junit Runner:

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

How am I running the tests:

./activator clean compile test

The kind of logs I'm getting:

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]

I'm new to jvm-cucumber and play please I would be very glad if someone could help me :) I'll keep you posted if I got anything new.

Update:

I don't know why but the "Before" and the "Given" clauses don't print any debug logs. Any other do.

like image 820
fonsecas72 Avatar asked Dec 10 '15 15:12

fonsecas72


1 Answers

For my Maven project with cucumber and webdriver the solution was to add a file to "/resources/logback.xml" with the same content as below.

So it should be able to do the same for the playframework. Create a "conf/resources/logback.xml" with the content:

<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>

(Source: https://stackoverflow.com/a/8936580/2827420)

like image 176
user24502 Avatar answered Sep 30 '22 13:09

user24502