Search code examples
jenkinswebdriverbrowserstack

BrowserStack - Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure


In my local Jenkins Docker container, I could run my test plan without any issues . Even without giving enter image description here

However, in my office Jenkins server, I setup with that as per the https://www.browserstack.com/docs/automate/selenium/jenkins#configuring-browserstack-credentials

Yet I get this error.

    org.openqa.selenium.remote.UnreachableBrowserException: 
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'hidden', ip: 'hidden', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.15.2.el7.x86_64', java.version: '1.8.0_201'
Driver info: driver.version: RemoteWebDriver
    at com.sam.browserstack.BrowserStackInitiation.setUp(BrowserStackInitiation.java:78)
Caused by: java.net.SocketTimeoutException: connect timed out
    at com.sam.browserstack.BrowserStackInitiation.setUp(BrowserStackInitiation.java:78)

My build command is as per below.

export M2_HOME=/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven3
export PATH=$PATH:$M2_HOME/bin
mvn --version

cd CommonPagesStorage
mvn clean install -DskipTests
cd ..
cd AutomationFrameworkDemo
mvn clean test -Dbrowser="${Browser}" -Dbrowser_version="${browser_version}" -Dos_version="10" -Dos="Windows" -Dlocalrun="false"  -Dtestxml=src/test/TestSuites/${TestPlanName}

I also tried adding below code as exports but no avail.

export http_proxy="http://proxy-dev.can.myorg.com:8080"
export https_proxy="http://proxy-dev.can.myorg.com:8080"
export NO_PROXY=123.345.145.345,.can.myorg.com,localhost,200.0.0.2

Solution

  • I got the url whitelisted from netwrok team, also below lines of code were needed too.

    https://username:password@hub-cloud.browserstack.com/wd/hub

    (Since I use free style project, to get M2_HOME, I created a maven project with just mvn --version as a shell command and got the value from output console)

    export M2_HOME=/opt/software/apache-maven-3.6.3
    export PATH=$PATH:$M2_HOME/bin
    export http_proxy="http://proxy-dev.aws.skynet.com:8080"
    export https_proxy="http://proxy-dev.aws.skynet.com:8080"
    export NO_PROXY=777.777.777.777,.aws.skynet.com,localhost,127.0.0.1
    mvn --version
    cd CommonPagesStorage
    mvn clean install -DskipTests
    cd ..
    cd AutomationFrameworkDemo
    mvn clean test -Dhttp.proxyHost=proxy-dev.aws.skynet.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy-dev.aws.skynet.com -Dhttps.proxyPort=8080 -Dbrowser="${Browser}" -Dbrowser_version="${browser_version}" -Dos_version="10" -Dos="Windows" -Dlocalrun="false"  -Dtestxml=src/test/TestSuites/${TestPlanName}