2

We are creatign a POC for running testcafe and browserstack in our jenkins. the jenkins file starts a node instance, starts upp browserstack local, runs the tests and then closes browserstack local. The browserstack local log indicates that it works ok, but the console states "ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure."

i can se in browserstack dashboard that the browser is started and is given an URL (example: http://127.0.0.1:44138/browser/connect/bl5rZIw) but the browser gives a "unable to connect to the page"

if i change from browserstack to a local chrome everything works. and if i run things on my local mashine it works (with browserstack.)

the networkpepole cant find any relevant blocks in the firewall. only calls to githubb. (185.199.110.153, TCP/443,140.82.121.3, TCP/443 - BLOCKERAT,140.82.121.5, TCP/443 - BLOCKERAT, 140.82.121.6, TCP/443 - BLOCKERAT)

any ideas on what is missing or how to digg into this problem.

relevant files ------------jenkins.openshift--------------------------

node('nodejs-14') {
  withRepository {
    stage('Install dependencies') {
      withProxy {
        sh 'npm install'
      }
    }
    stage('Test') {
      withProxy {
        withEnv([
          "BROWSERSTACK_LOCAL_IDENTIFIER=${env.BUILD_TAG}",
          "BROWSERSTACK_USERNAME=<secret :)>",
          "BROWSERSTACK_ACCESS_KEY=<secret :)>"
        ]) {
          try {
            sh "src/support/linux/BrowserStackLocal --key ${env.BROWSERSTACK_ACCESS_KEY} --local-identifier ${env.BUILD_TAG} --daemon start  --force-local  --proxy-host rbp-openshift-registry-001.wa.loc --proxy-port 3128 --local-proxy-host <secter :)> --local-proxy-port 3128  --verbose 2   --log-file ${env.WORKSPACE}/browserstack.log"
            sh "npm test"
          } finally {
            sh "src/support/linux/BrowserStackLocal --key ${env.BROWSERSTACK_ACCESS_KEY} --local-identifier ${env.BUILD_TAG} --daemon stop"
            archiveArtifacts artifacts: 'browserstack.log'
          }
        }
      }
    }
  }
}

--------------------package.json--------------------------------

{
  "name": "testcafe-poc",
  "version": "1.0.0",
  "description": "A Proof of Concept  project and template for running testcafe and browserstack. ",
  "main": "index.js",
  "scripts": {
    "test": "node_modules/.bin/testcafe  'browserstack:chrome@93.0:Windows 10' --hostname 127.0.0.1  --proxy rbp-openshift-registry-001.wa.loc:3128  ./src/tests/test1.js"
  },
  "repository": {
    "type": "git",
    "url": "ssh://git@code.resurs.loc:7999/test/testcafe-poc.git"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "testcafe": "1.9.4",
    "testcafe-browser-provider-browserstack": "1.13.1"
  },
  "dependencies": {}
}
Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47

2 Answers2

3

You mentioned that everything works fine locally without Jenkins. This means that there is no error in TestCafe of BrowserStack.

Probably, the issue is in your BrowserStack Local configuration. The testcafe-browser-provider-browserstack already has its own BrowserStackLocal instance, so it's not necessary to use BrowserStackLocal from src/support/linux/BrowserStackLocal.

Please refer to the following issue to see how to setup BrowserStack proxy settings: https://github.com/DevExpress/testcafe-browser-provider-browserstack#browserstack-proxy-options.

Alex Kamaev
  • 6,198
  • 1
  • 14
  • 29
  • 1
    The solutions was simpler and ridicolus. We used a % in our sting for. --local-identifier And that makes the browserstack local. fail to connect. But it does not tell you this in the loggs or documentation. So solution. dont use special characters in --local-identifier :) – Christoffer W Oct 19 '21 at 06:19
1

The solution was simple and ridiculous. We used a % in our sting for --local-identifier and that makes the BrowserStack local fail to connect. But it does not tell you this in the logs or documentation.

So the solution is: don't use special characters in the --local-identifier.

Shaido
  • 27,497
  • 23
  • 70
  • 73