Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Error MainClientExec:103 - Connection discarded

I developed a Selenium Project in Java and it worked fine.But when I tried to call it from a different project for integrating purpose it is giving this error as I mentioned below.

    2016-07-25 16:29:06 DEBUG RequestAddCookies:122 - CookieSpec selected: default
    2016-07-25 16:29:06 DEBUG RequestAuthCache:76 - Auth cache not set in the context
    2016-07-25 16:29:06 DEBUG PoolingHttpClientConnectionManager:249 - Connection request: [route: {}->http://localhost:13517][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
    2016-07-25 16:29:06 DEBUG PoolingHttpClientConnectionManager:282 - Connection leased: [id: 0][route: {}->http://localhost:13517][total kept alive: 0; route allocated: 1 of 2000; total allocated: 1 of 2000]
    2016-07-25 16:29:06 DEBUG MainClientExec:234 - Opening connection {}->http://localhost:13517
    2016-07-25 16:29:06 DEBUG DefaultHttpClientConnectionOperator:131 - Connecting to localhost/127.0.0.1:13517
    2016-07-25 16:29:06 DEBUG DefaultHttpClientConnectionOperator:138 - Connection established 127.0.0.1:52920<->127.0.0.1:13517
    2016-07-25 16:29:06 DEBUG DefaultManagedHttpClientConnection:90 - http-outgoing-0: set socket timeout to 10800000
    2016-07-25 16:29:06 DEBUG MainClientExec:255 - Executing request POST /session HTTP/1.1
    2016-07-25 16:29:06 DEBUG MainClientExec:260 - Target auth state: UNCHALLENGED
    2016-07-25 16:29:06 DEBUG MainClientExec:266 - Proxy auth state: UNCHALLENGED
    2016-07-25 16:29:06 DEBUG headers:135 - http-outgoing-0 >> POST /session HTTP/1.1
    2016-07-25 16:29:06 DEBUG headers:138 - http-outgoing-0 >> Content-Type: application/json; charset=utf-8
    2016-07-25 16:29:06 DEBUG headers:138 - http-outgoing-0 >> Content-Length: 122
    2016-07-25 16:29:06 DEBUG headers:138 - http-outgoing-0 >> Host: localhost:13517
    2016-07-25 16:29:06 DEBUG headers:138 - http-outgoing-0 >> Connection: Keep-Alive
    2016-07-25 16:29:06 DEBUG headers:138 - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_77)
    2016-07-25 16:29:06 DEBUG headers:138 - http-outgoing-0 >> Accept-Encoding: gzip,deflate
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "POST /session HTTP/1.1[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "Content-Type: application/json; charset=utf-8[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "Content-Length: 122[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "Host: localhost:13517[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_77)[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 >> "[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:86 - http-outgoing-0 >> "{"desiredCapabilities":{"browserName":"chrome","chromeOptions":{"args":[],"extensions":[]},"version":"","platform":"ANY"}}"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 << "Content-Length:689[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 << "Content-Type:application/json; charset=utf-8[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 << "Connection:close[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:72 - http-outgoing-0 << "[\r][\n]"
    2016-07-25 16:29:06 DEBUG wire:86 - http-outgoing-0 << "{"sessionId":"8130f26be5faa0e88b1342ad068e1fd0","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4)","userDataDir":"C:\\Users\\rahal\\AppData\\Local\\Temp\\scoped_dir10508_15086"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"platform":"Windows NT","rotatable":false,"takesHeapSnapshot":true,"takesScreenshot":true,"version":"51.0.2704.103","webStorageEnabled":true}}"
    2016-07-25 16:29:06 DEBUG headers:124 - http-outgoing-0 << HTTP/1.1 200 OK
    2016-07-25 16:29:06 DEBUG headers:127 - http-outgoing-0 << Content-Length:689
    2016-07-25 16:29:06 DEBUG headers:127 - http-outgoing-0 << Content-Type:application/json; charset=utf-8
    2016-07-25 16:29:06 DEBUG headers:127 - http-outgoing-0 << Connection:close
    2016-07-25 16:29:06 DEBUG DefaultManagedHttpClientConnection:81 - http-outgoing-0: Close connection
    2016-07-25 16:29:06 DEBUG MainClientExec:103 - Connection discarded

I found the Jason Data of the Error Report

{   "sessionId": "8be0897af892264346d7d8f7b3e4e7fe",   "status": 33,  
     "value": {
         "message": "session not created exception\nfrom disconnected: received Inspector.detached event\n  (Session info:
     chrome=51.0.2704.103)\n  (Driver info: chromedriver=2.21.371459
     (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0
     x86_64)"   } }

I added the Maven dependencies as follows

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>review-amender</groupId>
    <artifactId>review-amender</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <description>This project intergrate Dataextractor,Preporcessore, RAUpgradeTest</description>
    <build>
        <!-- <sourceDirectory>src</sourceDirectory> -->
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>it.codegen.rnd</groupId>
            <artifactId>data-extractor</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>

</project>

The thing is program don't terminate due to any Exception , and The Chrome Web driver don't stop its working process either.
When I run the Selenium Project from inside it works well.But not from the outside of the project even if I added the necessary dependencies.

Problem:Why this Selenium Project demonstrate unpredictable behavior,Is this happens because of due to a Maven Dependency Problem?

Please Help

like image 400
Rahal Kanishka Avatar asked Jul 25 '16 11:07

Rahal Kanishka


2 Answers

My guess is that what you are seeing is due to a maven dependency issue. I ran into a similar problem at one point where the Chrome WebDriver would just crash due to a NumberFormatException whenever we tried to access it's cookies. The root there was an incompatible transitive dependency (e.g. it needed a particular version of a dependency and our project was pulling in an older version and maven thought it was all ok). In our case the fix was to explicitly add the dependency on the correct version in our test project that was running the selenium tests. Unfortunately, I can't be more clear than that since I don't know the maven dependency structure of the projects in question. Try looking at:

mvn dependency:tree

and then check the versions of the web driver dependencies.

Also it looks like you are using chrome web driver 2.21 and chrome 51. The current chrome web driver is 2.22 and the release notes state it fixes a lot of issues with chrome 51

https://sites.google.com/a/chromium.org/chromedriver/downloads

Edit (adding): Also, not sure if the code execution is getting to perform any code at all, but it sounds like that exception can happen if the dev tools are open as that will disconnect the Chrome WebDriver from the Chrome browser. getting selenium error - disconnected: received Inspector.detached event using chrome driver version 2.20.x

like image 140
Aaron Davis Avatar answered Nov 11 '22 12:11

Aaron Davis


As chrome releases their latest version 2.22(2016-06-06) which supports Chrome v49-52, they have fixed some areas. Changes include many bug fixes, particularly for Chrome 51+.

For change details, please refer to the notes.

They have resolved a session related issue issue#1355

So Please update your chrome driver version and use updated selenium version.

like image 39
SkyWalker Avatar answered Nov 11 '22 12:11

SkyWalker