fail to connect mobile browser
Author: tracyluckyCreated Aug 29, 2022Updated Jun 27, 2026
Labelsenhancement
Description of the bug/issue
When I run my cucumber + nightwatch test case by browserstack, desktop works fine, but mobile browser cannot be connected
Steps to reproduce
When run the env with iPhone13(please refer to the nightwatch.conf.js in sample test), it returned Failed to connect to Selenium Server on hub-cloud.browserstack.com with port 443. I saw the build was started in browserstack dashboard, but not running my test case, could you please take a look, thanks a lot
Sample test
No response
Command to run
No response
Verbose Output
LogsConnecting to hub-cloud.browserstack.com on port 443...
Request POST https://hub-cloud.browserstack.com/wd/hub/session
{
desiredCapabilities: {
browserName: 'chrome',
'bstack:options': {
userName: 'xxxxxxxxxxxxx',
accessKey: 'xxxxxxxxxxxxx',
localIdentifier: 'nwstarter-test',
local: 'true'
},
chromeOptions: { w3c: false },
acceptSslCerts: true,
'browserstack.debug': true,
'browserstack.key': ‘xxxxxxxxxxxxx',
'browserstack.user': ‘xxxxxxxxx',
build: 'nightwatch-test-build',
name: 'Verify app image is displayed',
'goog:chromeOptions': {}
},
capabilities: {
alwaysMatch: {
browserName: 'chrome',
'bstack:options': {
userName: 'xxxxxxxxxxxxx',
accessKey: 'xxxxxxxxxxxxx',
localIdentifier: 'nwstarter-test',
local: 'true'
},
'goog:chromeOptions': {}
}
}
⠙ Connecting to hub-cloud.browserstack.com on port 443...
Response 200 POST https://hub-cloud.browserstack.com/wd/hub/session (5886ms)
{
value: {
sessionId: '5c8b0cab1b527a61978d92499d5414c9772b0239',
capabilities: {
acceptInsecureCerts: true,
browserName: 'chrome',
browserVersion: '104.0.5112.79',
chrome: {
chromedriverVersion: '104.0.5112.29 (eff877e18f767c77fef0481a1cba402c8cbad404-refs/branch-heads/5112@{#422})',
userDataDir: '/var/folders/3y/zz_w6_s56sl__vcrf3r5bhzr0000hr/T/.com.google.Chrome.ONfywX'
},
'goog:chromeOptions': { debuggerAddress: 'localhost:51048' },
networkConnectionEnabled: false,
pageLoadStrategy: 'normal',
platformName: 'mac os x',
proxy: {},
setWindowRect: true,
strictFileInteractability: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
unhandledPromptBehavior: 'dismiss and notify',
'webauthn:extension:credBlob': true,
'webauthn:extension:largeBlob': true,
'webauthn:virtualAuthenticators': true,
'webdriver.remote.sessionid': '5c8b0cab1b527a61978d92499d5414c9772b0239'
}
}
ℹ Connected to hub-cloud.browserstack.com on port 443 (5895ms).
Using: chrome (104.0.5112.79) on MAC OS X.
Received session with ID: 5c8b0cab1b527a61978d92499d5414c9772b0239
Request GET https://api.browserstack.com/automate/builds.json
.
→ Running command: url ('https://test.com/')
⠋ Loading url: https://test.com/
Request POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/url
{
url: 'https://test.com/'
⠇ Loading url: https://test.com/
Response 200 GET https://api.browserstack.com/automate/builds.json (1547ms)
[
{
automation_build: {
name: 'nightwatch-test-build',
duration: 7273884,
status: 'running',
hashed_id: '297d5e195b015a946858167105c430ceba12deeb',
build_tag: null
}
},
{
automation_build: {
name: 'e2e',
duration: 2777,
status: 'running',
hashed_id: '3c1c0cb2f4059c584535c1f67ea36d84c510fafd',
build_tag: null
}
},
{
automation_build: {
name: 'Nightwatch - iPhone13 ios 15',
duration: 344654,
status: 'running',
hashed_id: '644ca5b5345fef92ec8de2be255269e180f1ff56',
build_tag: null
}
},
{
automation_build: {
name: 'Nightwatch - iPhone XS ios 12',
duration: 31513206,
status: 'timeout',
hashed_id: 'd6981b5d9f9a3468ec00339d04b0b18963da5dbd',
build_tag: null
}
},
{
automation_build: {
name: 'e2e Archived 16',
duration: 2316454,
status: 'timeout',
hashed_id: 'ea5b2a729607f4467bde015405efd33f8aa83b41',
build_tag: null
}
},
{
automation_build: {
name: 'Nightwatch - iPad 5 ios 11',
duration: 522,
status: 'timeout',
hashed_id: 'e5cdddc96bcfe212c0920500ca970b180dd39310',
build_tag: null
}
},
{
automation_build: {
name: 'browserstack-build-1',
duration: 913153,
status: 'done',
hashed_id: '080d10ba686208593e789860bde7992ccd02f090',
build_tag: null
}
},
{
automation_build: {
name: 'Nightwatch - macos Catalina Safari latest',
duration: 18490405,
status: 'done',
hashed_id: '8ecadc9109652fa2815b4106085ab436e281e46e',
build_tag: null
}
},
{
automation_build: {
name: 'Nightwatch automation for MIS UI. Device: Samsung Galaxy S8',
duration: 30591380,
status: 'failed',
hashed_id: '4dffbb2b654fab636cab21ddf40e726c79db4272',
build_tag: null
}
},
{
automation_build: {
name: 'Nightwatch automation for MIS UI. Device: iPhone13 ios 15.5',
duration: 1032753,
status: 'timeout',
hashed_id: 'c30ee460b3b78a72d080c7609bad691791beb6ab',
build_tag: null
}
}
⠙ Loading url: https://test.com/
Response 500 POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/url (6739ms)
{
value: {
error: 'unknown error',
message: 'unknown error: net::ERR_CONNECTION_CLOSED\n' +
' (Session info: chrome=104.0.5112.79)',
stacktrace: ''
}
ℹ Loaded url https://test.com/ in 6742ms
→ Completed command: url ('https://test.com/') (6744ms)
→ Running command: waitForElementVisible ('body', 120000)
Request POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements
{ using: 'css selector', value: 'body' }
Response 200 POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements (1004ms)
{
value: [
{
'element-6066-11e4-a52e-4f735466cecf': 'f872b9fa-958e-43bf-8e6d-f03f7d64f1aa'
}
]
}
Request POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/execute/sync
{
script: 'return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a... (44027 characters)',
args: [
{
'element-6066-11e4-a52e-4f735466cecf': 'f872b9fa-958e-43bf-8e6d-f03f7d64f1aa',
ELEMENT: 'f872b9fa-958e-43bf-8e6d-f03f7d64f1aa'
}
]
}
Response 200 POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/execute/sync (1603ms)
{ value: true }
✔ Element <body> was visible after 2612 milliseconds.
→ Completed command: waitForElementVisible ('body', 120000) (2616ms)
.[info] verify the image
→ Running command: assert.visible ('#image0_1175\:6400', 'should show the sailing image when app with app name helloworld-test runs successfully')
→ Running command: isVisible ({selector, suppressNotFoundErrors}, [Function])
Request POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements
{ using: 'css selector', value: '#image0_1175\\:6400' }
Response 200 POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements (994ms)
{ value: [] }
Request POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements
{ using: 'css selector', value: '#image0_1175\\:6400' }
Response 200 POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements (894ms)
{ value: [] }
Request POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements
{ using: 'css selector', value: '#image0_1175\\:6400' }
Response 200 POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements (922ms)
{ value: [] }
Request POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements
{ using: 'css selector', value: '#image0_1175\\:6400' }
Response 200 POST https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239/elements (960ms)
{ value: [] }
✖ should show the sailing image when app with app name helloworld-test runs successfully in 5000ms - expected "is visible" but got: "element could not be located" (5293ms)
at /Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:31:40
at Generator.next (<anonymous>)
at /Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:8:71
at new Promise (<anonymous>)
at __awaiter (/Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:4:12)
at World.<anonymous> (/Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:29:115)
→ Completed command: assert.visible ('#image0_1175\:6400', 'should show the sailing image when app with app name helloworld-test runs successfully') (5295ms)
→ Completed command: isVisible ({selector, suppressNotFoundErrors}, [Function]) (5291ms)
F
→ Running command: quit ()
Request DELETE https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239
Response 200 DELETE https://hub-cloud.browserstack.com/wd/hub/session/5c8b0cab1b527a61978d92499d5414c9772b0239 (2035ms)
{ state: 'success', status: 0, value: '', hCode: '13579246' }
→ Completed command: quit () (2037ms)
.
Failures:
1) Scenario: Verify app image is displayed # features/helloworld.feature:4
✔ Before # node_modules/nightwatch/cucumber-js/_setup_cucumber_runner.js:6
✔ Given I navigated to my app link named <helloworld-test> # dist/definitions/helloworld-definitions.js:21
✖ Then verify the sailing image is on the hello world page on my app named <helloworld-test> # dist/definitions/helloworld-definitions.js:29
should show the sailing image when app with app name helloworld-test runs successfully in 5000ms - expected "is visible" but got: "element could not be located" (5293ms)
at Proxy.<anonymous> (/Users/test/Workspace/helloworld-test/src/__tests__/automation/node_modules/nightwatch/lib/api/index.js:145:30)
at /Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:31:40
at Generator.next (<anonymous>)
at /Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:8:71
at new Promise (<anonymous>)
at __awaiter (/Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:4:12)
at World.<anonymous> (/Users/test/Workspace/helloworld-test/src/__tests__/automation/dist/definitions/helloworld-definitions.js:29:115)
✔ After # node_modules/nightwatch/cucumber-js/_setup_cucumber_runner.js:66
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
0m22.764s (executing steps: 0m22.753s)Nightwatch Configuration
nightwatch.conf.jsconst bstackOptions = {
'bstack:options' : {
userName: '${BROWSERSTACK_USERNAME}',
// eslint-disable-next-line no-template-curly-in-string
accessKey: '${BROWSERSTACK_ACCESS_KEY}',
// eslint-disable-next-line no-template-curly-in-string
localIdentifier: '${BROWSERSTACK_LOCAL_IDENTIFIER}',
local: 'true',
},
}
module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as
// the second argument to the test runner.
src_folders: ['./dist/definitions'],
// See https://nightwatchjs.org/guide/working-with-page-objects/using-page-objects.html
page_objects_path: ['node_modules/nightwatch/examples/pages/'],
// See https://nightwatchjs.org/guide/extending-nightwatch/custom-commands.html
custom_commands_path: ['node_modules/nightwatch/examples/custom-commands/'],
// See https://nightwatchjs.org/guide/extending-nightwatch/custom-assertions.html
custom_assertions_path: '',
// See https://nightwatchjs.org/guide/extending-nightwatch/plugin-api.html
plugins: [],
// See https://nightwatchjs.org/guide/#external-globals
globals_path: '',
webdriver: {},
test_runner: {
// set cucumber as the runner
type: 'cucumber',
// define cucumber specific options
options: {
//set the feature path
feature_path: 'features/*.feature',
// start the webdriver session automatically (enabled by default)
auto_start_session: true,
// use parallel execution in Cucumber
parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2
}
},
selenium: {
host: 'hub-cloud.browserstack.com',
port: 443,
webdriver: {
start_process: false,
server_path: '',
cli_args: [
// --verbose
],
},
},
test_settings: {
default: {
// More info on configuring capabilities can be found on:
// https://www.browserstack.com/automate/capabilities?tag=selenium-4
desiredCapabilities: {
...bstackOptions,
browserName: 'chrome',
// add other capabilities you want
chromeOptions: {
w3c: false,
},
acceptSslCerts: true,
'browserstack.debug': true,
},
disable_error_log: true,
webdriver: {
timeout_options: {
timeout: 15000,
retry_attempts: 3,
},
keep_alive: true,
start_process: false,
},
},
safari: {
...bstackOptions,
desiredCapabilities: {
browserName: 'safari',
alwaysMatch: {
acceptInsecureCerts: false,
},
},
webdriver: {
start_process: true,
server_path: '',
},
},
firefox: {
...bstackOptions,
desiredCapabilities: {
browserName: 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: [
// '-headless',
// '-verbose'
],
},
},
},
webdriver: {
start_process: true,
server_path: '',
cli_args: [
// very verbose geckodriver logs
// '-vv'
],
},
},
chrome: {
desiredCapabilities: {
...bstackOptions,
browserName: 'chrome',
'goog:chromeOptions': {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol
// (not required in Chrome 78)
w3c: false,
args: [
// '--no-sandbox',
// '--ignore-certificate-errors',
// '--allow-insecure-localhost',
// '--headless'
],
},
},
},
edge: {
desiredCapabilities: {
...bstackOptions,
browserName: 'edge',
}
},
iPhone13: {
selenium: {
host: 'hub-cloud.browserstack.com',
port: 443,
"start_process" : false,
},
desiredCapabilities: {
'bstack:options' : {
"osVersion" : "15",
"deviceName" : "iPhone 13",
"realMobile" : "true",
"local" : "true",
"userName" : "xxxxxxxxxxx",
"accessKey" : "xxxxxxxxxxxxxxxx",
"idleTimeout": 300
},
"browserName" : "safari",
build: 'Nightwatch - iPhone13 ios 15',
},
},
selenium_server: {
selenium: {
host: 'localhost',
port: 4444,
},
webdriver: {
start_process: true,
},
},
'selenium.chrome': {
extends: 'selenium_server',
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
w3c: false,
},
},
},
'selenium.firefox': {
extends: 'selenium_server',
desiredCapabilities: {
browserName: 'firefox',
'moz:firefoxOptions': {
args: [
// '-headless',
// '-verbose'
],
},
},
},
},
};Nightwatch.js Version
2.0.10
NPM Version
6.14.8
Node Version
14.17.5
Yarn Version
No response
Browser
safari
Operating System
ios
Additional Information
No response
Source: nightwatchjs/nightwatch