我正在将Nightwatch与BrowserStack一起使用以在Edge 17女士上运行测试套件,并且在大多数版本中都遇到以下错误。
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{
value: { message: 'Could not start Browser / Emulator' },
sessionId: '',
status: 13
}
我们在BrowserStack中的chrome浏览器上运行的代码完全相同,没有任何问题。 该套件使用工作程序并行运行。如果我禁用了工作程序,那么它会通过,不幸的是,我们需要使用并行执行,否则套件将花费太长时间。
我将在下面发布我们的配置文件。
var seleniumJar = require('selenium-server-standalone-jar')
var nightwatchWorkers = parseInt(process.env.NIGHTWATCH_WORKER_THREADS) || 1
var chromeDriver = process.env.CHROME_DRIVER_PATH || './drivers/chromedriver'
var msEdgeDriverPath = process.env.MSEDGE_DRIVER_PATH || './drivers/MicrosoftWebDriver.exe'
var ie11DriverPath = process.env.MSIE11_DRIVER_PATH || './drivers/IEDriverServer.exe'
var localDockerPort = 4444
var browserStackPort = 80
var browserStackHost = 'hub-cloud.browserstack.com'
var browserStackScreenResolution = '1920x1200'
module.exports = {
src_folders: ['./tests'],
output_folder: './results',
live_output: true, //set to false so each thread will output the whole result of the test when it's done
silent: true,
custom_commands_path: './commands',
custom_assertions_path: './assertions',
page_objects_path: './pages',
test_workers: {
enabled: true,
workers: nightwatchWorkers
},
selenium: {
start_process: false,
server_path: seleniumJar.path,
log_path: './results',
port: localDockerPort,
cli_args: {
'webdriver.chrome.driver': chromeDriver,
'webdriver.edge.driver': msEdgeDriverPath,
'webdriver.ie.driver': ie11DriverPath
}
},
test_settings: {
default: {
launch_url: 'http://localhost',
selenium_host: '127.0.0.1',
selenium_port: localDockerPort,
silent: true,
disable_colors: false,
screenshots: {
enabled: true,
on_failure: true,
path: './results/screenshots'
},
desiredCapabilities: {
browserName: 'chrome',
resolution: browserStackScreenResolution,
javascriptEnabled: true,
acceptSslCerts: true,
elementScrollBehavior: 1,
project: 'megarepo',
build: process.env.BROWSERSTACK_BUILD_ID,
'browserstack.user': process.env.BROWSERSTACK_USER,
'browserstack.key': process.env.BROWSERSTACK_KEY
},
globals: require('./data/dev')
},
browserstack_msedge: {
selenium: {
port: browserStackPort
},
selenium_host: browserStackHost,
selenium_port: browserStackPort,
detailed_output: false,
desiredCapabilities: {
os: 'Windows',
os_version: '10',
browserName: 'Edge',
browser_version: '17.0',
resolution: browserStackScreenResolution
}
}
}
}
我们在BrowserStack中的chrome浏览器上运行的代码完全相同,没有任何问题。 该套件使用工作程序并行运行。如果我禁用了工作程序,那么它会过去,不幸的是,我们需要使用并行执行,否则套件将花费很长时间。