Webdriver.io - can not get firefox to run - selenium

I am trying to get firefox to run in webdriver.io 5. This is on a Linux cloud.
I get:
2020-02-28T02:32:33.472Z INFO #wdio/cli:launcher: Run onPrepare hook
2020-02-28T02:32:33.475Z INFO #wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js
[0-0] 2020-02-28T02:32:33.818Z INFO #wdio/local-runner: Run worker command: run
[0-0] RUNNING in firefox - /build/main.js
[0-0] 2020-02-28T02:32:33.881Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-02-28T02:32:33.883Z INFO webdriver: [POST] http://127.0.0.1:4444/session
[0-0] 2020-02-28T02:32:33.883Z INFO webdriver: DATA {
capabilities: {
alwaysMatch: { browserName: 'firefox', 'moz:firefoxOptions': [Object] },
firstMatch: [ {} ]
},
desiredCapabilities: { browserName: 'firefox', 'moz:firefoxOptions': { args: [Array] } }
}
[0-0] 2020-02-28T02:32:33.899Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
[0-0] 2020-02-28T02:32:33.899Z INFO webdriver: Retrying 1/3
Here is my config:
exports.config = {
runner: 'local',
path: '/',
specs: [
'./build/**/*.js'
],
maxInstances: 10,
capabilities: [
{
"browserName": "firefox",
"moz:firefoxOptions": {
"args": ["-headless"],
}
}
],
logLevel: 'info',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
reporters: ['spec'],
framework: 'mocha',
mochaOpts: {
ui: 'bdd',
timeout: 60000
},
services: [
],
}```
Any ideas what I am doing wrong?

The path should be set to path: "/wd/hub" and your services seems to be empty. You can use webdriverio with mocha in two different ways. With selenium or without.
Please refer to boiler plates from official docs here

[0-0] 2020-02-28T02:32:33.899Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
If you are using selenium-standalone, please make sure that you have both the java jdk & sdk installed on your machine. let me know if this worked for you.

Related

How to run an acceptance test in Codeception in Opera Browser?

When I run the test, Opera opens, but the test does not run and an error falls into the console
[Facebook\WebDriver\Exception\SessionNotCreatedException] Unable to create session from {
"desiredCapabilities": {
"browserName": "opera"
},
"capabilities": {
"firstMatch": [
{
"browserName": "opera"
}
]
}
}
Driver info: driver.version: unknown
I start the server with this command:
java "-Dwebdriver.opera.driver=C:\Users\user\Desktop\Auto\qa-tests\Codeception\operadriver.exe" -jar "C:\Users\user\Desktop\Auto\qa-tests\Codeception\selenium-server-standalone-3.14.0.jar"
My acceptance.suite.yaml
opera:
modules:
config:
PhpBrowser:
url: 'https://sample.com/'
WebDriver:
url: 'https://samlpe.com/'
window_size: 1900x1080 # for fullscreen shots
port: 17570
browser: opera # 'chrome' or 'firefox' java "-Dwebdriver.opera.driver=C:\Users\user\Desktop\Auto\qa-tests\Codeception\operadriver.exe" -jar "C:\Users\user\Desktop\Auto\qa-tests\Codeception\selenium-server-standalone-3.14.0.jar" -port 17570 - для MicrosoftEdge
#capabilities:
args: [ '--no-sandbox' ]

appium XCUITest ios (React-native) app not launching

i have completed setup of appium automation testing and it is running fine in android, but when its came to ios from command line i run "yarn testios", test cases are started to checking but the app is not launching? why this happening and what is solution for that please guid me .....
i have mentioned setup files below
// this is "wdio.ios.config.js" file
exports.config = {
path: '/wd/hub/',
port: 4729,
services: ['appium'],
runner: 'local',
specs: [
'./test-ios/specs/**/*.js'
],
exclude: [
],
maxInstances: 1,
capabilities: [{
maxInstances: 1,
browserName: '',
appiumVersion: '1.22.0',
platformName: 'iOS',
platformVersion: '14.4',
deviceName: 'iPhone 11 Pro',
automationName: 'XCUITest',
acceptInsecureCerts: true,
appWaitDuration: 20000
}],
//app: '',
noReset: true,
// udid: '9084F2CE-E9B2-4632-B059-6506AA13A783',
udid: 'FF32131D-797C-447A-B67D-D5A244AC66DF',
autoLaunch: true,
bundleId: 'com.callboats',
logLevel: 'info',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 1,
services: ['appium'],
framework: 'mocha',
reporters: [['allure', {outputDir: 'allure-results'}],],
mochaOpts: {
ui: 'bdd',
timeout: 60000
},
afterTest: async function(test, context, { error, result, duration, passed, retries }) {
if (!passed) {
await browser.takeScreenshot();
}
},
}
// this is package.json file
{
"name": "testing_appium",
"version": "1.0.0",
"description": "automated testing with appium",
"main": "index.js",
"scripts": {
"testandroid": "npx wdio ./wdio.android.conf.js",
"testios": "npx wdio ./wdio.ios.conf.js"
},
"author": "TatvaSoft",
"license": "ISC",
"dependencies": {
"#wdio/cli": "^7.16.10",
"appium": "^1.22.1",
"asyncbox": "^2.9.2",
"chai": "^4.3.4",
"webdriverio": "^7.16.10"
},
"devDependencies": {
"#wdio/allure-reporter": "^7.16.10",
"#wdio/appium-service": "^7.16.6",
"#wdio/local-runner": "^7.16.10",
"#wdio/mocha-framework": "^7.16.6",
"wdio-mochawesome-reporter": "^4.0.0"
}
}
// here is logs of terminal
pcq214#PCQ214 testing_appium %
pcq214#PCQ214 testing_appium % yarn testios
yarn run v1.22.10
warning ../../../../../../package.json: No license field
$ npx wdio ./wdio.ios.conf.js
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist#latest --update-db
Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
Execution of 1 workers started at 2021-12-17T09:37:28.281Z
2021-12-17T09:37:28.722Z INFO #wdio/cli:launcher: Run onPrepare hook
2021-12-17T09:37:41.615Z INFO #wdio/cli:launcher: Run onWorkerStart hook
2021-12-17T09:37:41.616Z INFO #wdio/local-runner: Start worker 0-0 with arg: ./wdio.ios.conf.js
[0-0] 2021-12-17T09:37:44.352Z INFO #wdio/local-runner: Run worker command: run
[0-0] Browserslist: caniuse-lite is outdated. Please run:
[0-0] npx browserslist#latest --update-db
[0-0]
[0-0] Why you should do it regularly:
[0-0] https://github.com/browserslist/browserslist#browsers-data-updating
[0-0] RUNNING in iOS - /test-ios/specs/example.e2e.js
[0-0] 2021-12-17T09:37:49.187Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2021-12-17T09:37:50.505Z INFO webdriver: [POST] http://localhost:4723/session
[0-0] 2021-12-17T09:37:50.505Z INFO webdriver: DATA {
[0-0] capabilities: {
[0-0] alwaysMatch: {
[0-0] browserName: '',
[0-0] appiumVersion: '1.22.0',
[0-0] platformName: 'iOS',
[0-0] platformVersion: '14.4',
[0-0] deviceName: 'iPhone 11 Pro',
[0-0] automationName: 'XCUITest',
[0-0] acceptInsecureCerts: true,
[0-0] appWaitDuration: 20000
[0-0] },
[0-0] firstMatch: [ {} ]
[0-0] },
[0-0] desiredCapabilities: {
[0-0] browserName: '',
[0-0] appiumVersion: '1.22.0',
[0-0] platformName: 'iOS',
[0-0] platformVersion: '14.4',
[0-0] deviceName: 'iPhone 11 Pro',
[0-0] automationName: 'XCUITest',
[0-0] acceptInsecureCerts: true,
[0-0] appWaitDuration: 20000
[0-0] }
[0-0] }
[0-0] 2021-12-17T09:38:10.129Z INFO webdriver: COMMAND launchApp()
[0-0] 2021-12-17T09:38:10.129Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/appium/app/launch
[0-0] 2021-12-17T09:38:13.141Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:13.141Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:13.141Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
[0-0] 2021-12-17T09:38:14.133Z INFO webdriver: RESULT {
[0-0] error: 'no such element',
[0-0] message: 'An element could not be located on the page using the given search parameters.',
[0-0] stacktrace: 'NoSuchElementError: An element could not be located on the page using the given search parameters.\n' +
[0-0] ' at XCUITestDriver.doNativeFind (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:130:11)\n' +
[0-0] ' at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
[0-0] ' at XCUITestDriver.findNativeElementOrElements (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:90:10)\n' +
[0-0] ' at XCUITestDriver.findElOrEls (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:23:12)\n' +
[0-0] ' at XCUITestDriver.findElOrElsWithProcessing (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n' +
[0-0] ' at XCUITestDriver.findElement (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)'
[0-0] }
[0-0] 2021-12-17T09:38:14.405Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:14.405Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:14.405Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
[0-0] 2021-12-17T09:38:14.566Z INFO webdriver: RESULT {
[0-0] error: 'no such element',
[0-0] message: 'An element could not be located on the page using the given search parameters.',
[0-0] stacktrace: 'NoSuchElementError: An element could not be located on the page using the given search parameters.\n' +
[0-0] ' at XCUITestDriver.doNativeFind (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:130:11)\n' +
[0-0] ' at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
[0-0] ' at XCUITestDriver.findNativeElementOrElements (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:90:10)\n' +
[0-0] ' at XCUITestDriver.findElOrEls (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:23:12)\n' +
[0-0] ' at XCUITestDriver.findElOrElsWithProcessing (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n' +
[0-0] ' at XCUITestDriver.findElement (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)'
[0-0] }
[0-0] 2021-12-17T09:38:14.889Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:14.890Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:14.890Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
[0-0] 2021-12-17T09:38:15.019Z INFO webdriver: RESULT {
[0-0] error: 'no such element',
[0-0] message: 'An element could not be located on the page using the given search parameters.',
[0-0] stacktrace: 'NoSuchElementError: An element could not be located on the page using the given search parameters.\n' +
[0-0] ' at XCUITestDriver.doNativeFind (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:130:11)\n' +
[0-0] ' at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
[0-0] ' at XCUITestDriver.findNativeElementOrElements (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:90:10)\n' +
[0-0] ' at XCUITestDriver.findElOrEls (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:23:12)\n' +
[0-0] ' at XCUITestDriver.findElOrElsWithProcessing (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n' +
[0-0] ' at XCUITestDriver.findElement (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)'
[0-0] }
[0-0] 2021-12-17T09:38:15.172Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:15.173Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:15.173Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
^C
Ending WebDriver sessions gracefully ...
(press ctrl+c again to hard kill the runner)
2021-12-17T09:38:15.204Z INFO #wdio/local-runner: Shutting down spawned worker
[0-0] 2021-12-17T09:38:15.204Z INFO #wdio/local-runner: Received SIGINT, giving process 5000ms to shutdown gracefully
[0-0] 2021-12-17T09:38:15.206Z INFO #wdio/local-runner: Run worker command: endSession
[0-0] 2021-12-17T09:38:15.206Z INFO webdriver: COMMAND deleteSession()
[0-0] 2021-12-17T09:38:15.206Z INFO webdriver: [DELETE] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403
//continue...........................................and fail cases because app is not launching
//here is starting of my test cases.....in "example.e2e.js"
// it will launch the application
describe('launch the app', ()=>{
before(()=>{
it("should launch the app", async ()=>{
let driver = await initSession();
//let driver = new AndroidDriver();
//await driver.launchApp('com.callboats');
//await driver.activateApp('com.callboats');
await driver.execute('mobile: launchApp');
await $("~map-view").waitForDisplayed(20000, false)
})
})
});
//it will check the flow of trip as anonymous user
describe('testing enjoy trip as anonymous user', ()=> {
it('should render mapView', async ()=>{
await driver.launchApp();
await browser.waitUntil(
async () => (await $("~settings-btn").isDisplayed()) == true,
{
timeout: 50000,
timeoutMsg: 'id(settings-btn) is not displayed'
}
);
await browser.waitUntil(
async () => (await $("~map-view").isDisplayed()) == true,
{
timeout: 50000,
timeoutMsg: 'id(map-view) is not displayed'
}
);
await browser.waitUntil(
async () => (await $("~main-mapview").isDisplayed()) == true,
{
timeout: 50000,
timeoutMsg: 'id(main-mapview) is not displayed'
}
);
}).....................continue
You are missing the bundleId value in your capabilities to launch the app.
capabilities: [{
maxInstances: 1,
browserName: '',
appiumVersion: '1.22.0',
platformName: 'iOS',
platformVersion: '14.4',
deviceName: 'iPhone 11 Pro',
automationName: 'XCUITest',
acceptInsecureCerts: true,
appWaitDuration: 20000,
*bundleId*: {value}
}],
Here is a reference on how to obtain the bundleId value

Running tests on browserstack throws "Cannot read property 'capabilities' of null"

I am running tests using wdioV5 and browserstack but I am getting the following error:
ERROR #wdio/local-runner: Failed launching test session: TypeError: Cannot read property 'capabilities' of null
I tried to check the debug logs but unable to figure the reasoning behind it, has anyone faced a similar issue?
DEBUG output:
[0-0] 2019-06-06T13:34:00.454Z INFO webdriver: Retrying 3/3
[0-0] 2019-06-06T13:34:00.455Z INFO webdriver: [POST] https://hub-cloud.browserstack.com:443/session
[0-0] 2019-06-06T13:34:00.455Z INFO webdriver: DATA { capabilities:
{ alwaysMatch:
{ os: 'Windows',
os_version: '10',
browser: 'Chrome',
browser_version: '73.0',
'browserstack.local': true },
firstMatch: [ {} ] },
desiredCapabilities:
{ os: 'Windows',
os_version: '10',
browser: 'Chrome',
browser_version: '73.0',
'browserstack.local': true } }
[0-0] 2019-06-06T13:34:00.480Z DEBUG webdriver: request failed due to status 13
[0-0] 2019-06-06T13:34:00.481Z ERROR webdriver: Request failed due to Error: Session not started or terminated
If it helps reproduce, my config is:
path: '/',
specs: [ './specs/**/*.js' ],
exclude: [],
maxInstances: 10,
capabilities:
[ { os: 'Windows',
os_version: '10',
browser: 'Chrome',
browser_version: '73.0' } ],
logLevel: 'trace',
bail: 0,
baseUrl: 'http://localhost:8000',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: [ 'browserstack' ],
framework: 'mocha',
reporters: [ 'spec' ],
mochaOpts: { timeout: 60000 },
before: [Function: before],
user: 'xxx',
key: 'xxx',
browserstackLocal: true,
onPrepare: [Function: onPrepare],
onComplete: [Function: onComplete] }
Figured it out... for some reason, having this option in the wdio.conf.js threw the error message above, the moment I removed it, it worked, which is mad:
path: '/'

Webdriver cannot connect to Selenium server

I am currently trying to set up webdriver and selenium together to run my automation tests through docker but am facing issues. Each time i try to run the tests I get the following error ERROR wdio-runner: Error: connect ECONNREFUSED 127.0.0.1:4444
I am using the selenium/standalone-chrome from docker and can see that the server is configured correctly and running at 127.0.0.1:4444 as I can hit it.
When I try to run webdriver however I seem to face the issue mentioned above. I believe the issue must be something in my webdriver config but having followed the documentation I can't see what's wrong...
const chai = require('chai');
const chaiWebdriver = require('chai-webdriverio').default;
const debug = process.env.DEBUG;
exports.config = {
runner: 'local',
host: '127.0.0.1',
port: 4444,
path: '/wd/hub',
specs: ['specs/**/*.js'],
suites: {
smoke: ['specs/smoke-spec.js']
},
maxInstances: 10,
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {}
},
sync: true,
logLevel: 'error',
coloredLogs: true,
deprecationWarnings: false,
bail: 0,
debug,
execArgv: debug ? ['--inspect'] : [],
screenshotOnReject: true,
screenshotPath: './error-screenshots',
baseUrl: https://localhost:443,
waitforTimeout: 30000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
seleniumLogs: './selenium-logs',
framework: 'mocha',
reporters: [
[
'allure',
{
outputDir: 'test-output',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false
}
],
['spec', {}]
],
mochaOpts: {
ui: 'bdd',
timeout: 400000,
compilers: ['js:babel-register']
},
before() {
chai.use(chaiWebdriver(browser));
global.expect = chai.expect;
},
afterTest: test => {
if (!test.passed) {
browser.takeScreenshot();
}
}
};

Unable to create firefox section selenium grid which is hosted on docker

Please check the details below:
I update - geckodriver: geckodriver-v0.20.1 up to date
Error:
firefox_1 | 11:39:06.089 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session a16899ff-8ef3-40b4-a7a3-406861b95c50 (org.openqa.selenium.firefox.GeckoDriverService)
nodeSetup_1 | [e2e] [11:39:06] E/launcher - Unable to parse new session response: {"value":{"sessionId":"a16899ff-8ef3-40b4-a7a3-406861b95c50","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"60.0.2","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":71,"moz:profile":"/tmp/rust_mozprofile.EvUy5THtLClM","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"linux","platformVersion":"3.19.0-25-generic","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"webdriver.remote.sessionid":"a16899ff-8ef3-40b4-a7a3-406861b95c50"}}}
nodeSetup_1 | [e2e] [11:39:06] E/launcher - WebDriverError: Unable to parse new session response: {"value":{"sessionId":"a16899ff-8ef3-40b4-a7a3-406861b95c50","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"60.0.2","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":71,"moz:profile":"/tmp/rust_mozprofile.EvUy5THtLClM","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"linux","platformVersion":"3.19.0-25-generic","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"webdriver.remote.sessionid":"a16899ff-8ef3-40b4-a7a3-406861b95c50"}}}
nodeSetup_1 | [e2e] at doSend.then.response (/usr/src/app/serenityjs/node_modules/selenium-webdriver/lib/http.js:445:19)
Code
Protractor conf:
multiCapabilities: [
{
browserName: 'firefox',
firefoxOptions: {
args: ['--headless',
'seleniumProtocol=Selenium'
]
},
'moz:firefoxOptions': {
args: [ '--headless',
'seleniumProtocol=Selenium'
]
}
}
],
Probably you set up capabilities in a wrong way. Try this one:
capabilities: {
'browserName': 'firefox',
'moz:firefoxOptions': {
'args': ['--headless']
}
},