webdriverIO test on sauceLabs is not working for firefox - selenium-webdriver

I am trying to run a wdio-test on saucelabs for chrome, IE and firefox.
test works fine for chrome and IE, however it fails for firefox with :
Infrastructure Error -- The Sauce VMs failed to start the browser or device.
I am using lastest version of wdio and sauce service:
"devDependencies": {
"#wdio/cli": "^6.1.5",
"#wdio/cucumber-framework": "^6.1.1",
"#wdio/local-runner": "^6.1.5",
"#wdio/sauce-service": "^6.1.0",
"#wdio/spec-reporter": "^6.1.5",
"#wdio/sync": "^6.1.5",
"chromedriver": "^81.0.0",
"wdio-chromedriver-service": "^6.0.2"
}
my browser config:
capabilities: [
{
maxInstances: 3,
browserName: "chrome",
browserVersion: "latest"
},
{
maxInstances: 3,
browserName: "firefox",
browserVersion: "latest",
platform: "windows 10",
"sauce:options": {
seleniumVersion: "3.14.0",
},
},
{
maxInstances: 3,
browserName: "internet explorer",
browserVersion: "latest"
},
],

This is an issue with how WebdriverIO and Sauce Labs handle W3C browser options. You do need to provide a sauce:options capability to use recent versions of Firefox, which would look like this:
capabilities: {
maxInstances: 3,
browserName: 'firefox',
platformName: 'Windows 10',
browserVersion: 'latest',
'sauce:options':
{'seleniumVersion': '3.14.0'}
}
The sauce:options specifies Sauce-only capabilities, such as which version of Selenium WebDriver to use in this case.

I was able to fix it.
In order for the W3C-compliant Selenium capabilities and protocol to work, all non-standard capabilities need to be defined inside the "sacue:options" block. This includes the "build" capability. Also, to specify a platform, the capability name has been changed from "platform" to "platformName". So the capabilities should look like this:
capabilities: {
browserName: 'firefox',
platformName: 'Windows 10',
browserVersion: 'latest',
'sauce:options':
{
'seleniumVersion': '3.14.0',
'build': buildName()
}
}

Related

Using headless chrome displays empty part of the page

When using chromedriver in a protractor script, to test an angular page, I obtain different results using "Headless" or "Normal" browser.
Actually, if I use a "repeater" locator, to display the items in the "empty" list, it returns that there are 5 items, but the "headless" chrome driver fails to render them. Look at the screenshots.
I'm using ChromeDriver 2.45, which supports Chrome Version 70 to 72, I have version 71.
My OS is Windows 10.
Protractor version 5.1.1
Angularjs version 1.5
Here's the configuration file:
exports.config = {
directConnect: true,
rootElement: 'html',
chromeDriver: 'C:\\srv\\build\\applications\\chromedriver\\chromedriver_win32\\chromedriver.exe',
getPageTimeout: 60000,
allScriptsTimeout: 60000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome',
chromeOptions:{
args:["--headless"]
}
},
specs: [ 'features/*.feature' ],
baseUrl: '',
cucumberOpts: {
tags: '',
require: [ 'steps/*.spec.js' ],
monochrome: true,
strict: true,
plugin: "json"
},
};
Seems to problem is in the window size. By default, headless mode is not a fullscreen, so some elements are automatically moved and hidden (as when you try manually to resize the window)
Just add to your conf:
driver.manage().window().maximize();
Can you update args to
capabilities: {
...,
chromeOptions: {
args: ["--headless", "--disable-gpu", "--window-size=800x600"]
}
}
For the exact configuration mentioned i am able to automate headless with no issues.
Reference https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-headless-chrome

Trying to run protractor tests in parallel

I'm trying to run a bunch of tests in parallel using protractor.. it seems that I am using all the configs as I should but something isn't right and the tests are running one after the other in the same browser instance.
my .conf file is as follows:
// Some protractor configs
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstance: 2,
},
suites: {
sitePersonalizationSanity: '../test/e2e/Sanity/*.js',
},
// Other protractor configs
I'll be glad to hear if I'm doing anything wrong.. thanks.
Your original problem was only with the spelling.
Use:
maxInstances: 2,
Instead of:
maxInstance: 2,
This could be your work around and works fro me.
you can specify the threads
in multicapabilities just mention like this
multiCapabilities: [
{
shardTestFiles: true,
maxInstances: 1,
sequential: true,
browserName: 'chrome',
specs: ['specs/spec1.js','specs/spec2.js','specs/spec3.js']
},
{
shardTestFiles: true,
maxInstances: 1,
sequential: true,
browserName: 'chrome',
specs: ['specs/spec4.js',
'specs/spec5.js',
'specs/spec6.js',
]
}
If you want you can include the maxSessions: 1, count: 1 too .
so that you can restrict the sessions
you can group the similar processing test cases together.
Hope this helps.
Kindly up-vote or select as correct answer if it works good.

Running both Chrome and IE 11 Protractor tests

Running Protractor E2E tests against both Chrome and IE is difficult.
I can run them separately, however I need to start/stop the respective Chrome/IE webdriver server before running each tests.
In my conf.js file, I export the config options like this :
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'spec/my-spec.js',
],
directConnect: false, // false when targeting IE, and selen addr is used
multiCapabilities: [
{
browserName: 'chrome'
}
,
{
browserName: 'internet explorer',
'version': '11'
}
]
}
For the standard Chrome tests, I can kick off the Webdriver server:
> webdriver-manager start
But for IE, I discovered a way to run Webdriver IE as follows (yeah, pretty ugly):
java -Dwebdriver.ie.driver=C:\Projects\GSDashboard-E2ETests\node_modules\protractor\node_modules\webdriver-manager\selenium\IEDriverServer_x64_2.53.1.exe -jar C:\Projects\GSDashboard-E2ETests\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-2.53.1.jar
Then I just launch the Protractor tests:
protractor protractor.conf.js
I'm searching around for a cleaner and smoother way of running both IE/Chrome e2e tests in one shot.
Is there a solution to this ?
Any advice/guidance is appreciated....
****** UPDATE ******
As per answer below, trying to use seleniumArgs as follows (where I can specify the jar file OR the IEDriverServer_x64_2.53.1.exe file :
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub', // comment out
seleniumArgs: ['-Dwebdriver.ie.driver=C:\Projects\Dashb-E2ETests\node_modules\protractor\node_modules\webdriver-manager\selenium\IEDriverServer_x64_2.53.1.exe'],
allScriptsTimeout: 50000,
specs: [
'spec/MY-spec.js',
],
directConnect: false, // false when targeting IE, and selen addr is used
multiCapabilities: [
//{
// browserName: 'chrome',
,
{
browserName: 'internet explorer',
'version': '11'
}
]
}
BUT running the test throws this error in a windows cmd prompt:
E/launcher - The path to the driver executable must be set by the web driver.ie.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorer‌​Driver.
So, I still haven't figured out how to run both IE and Chrome tests (sequentially).
regards,
Bob
I had a similar problem and the solution was running this:
webdriver-manager update --ie
After that, both IE11 and Chrome instances run simultaneously with:
multiCapabilities: [
{
browserName: 'chrome'
}
,
{
browserName: 'internet explorer',
'version': '11'
}
]
include seleniumArgs: ['-Dwebdriver.ie.driver=pathtoIEdriver/IEDriverServer.exe'] property in the conf.js and remove seleniumAddress: 'http://localhost:4444/wd/hub'.If no seleniumAddress is mentioned ,then protractor will automatically start selenium server. So following will be your conf.js for running your protractor test against chrome and ie.
exports.config = {
seleniumArgs: ['-Dwebdriver.ie.driver=node_modules/protractor/selenium/IEDriverServer.exe'],
specs: [
'spec/my-spec.js',
],
directConnect: false, // false when targeting IE, and selen addr is used
multiCapabilities: [
{
browserName: 'chrome'
}
,
{
browserName: 'internet explorer',
'version': '11'
}
]
}

Why is Protractor complaining about target browser config when I'm not targeting a browser?

I'm writing an app using Ionic/Angular and testing it with Protractor. I'd like to test it using Sauselabs Appium so I can test the app running natively on the various target platforms. I'm launching Protractor with:
SAUCE_USERNAME=$(SAUCE_USERNAME) SAUCE_ACCESS_KEY=$(SAUCE_ACCESS_KEY) ./node_modules/.bin/protractor protractorConfig.js
But I get this error message:
[launcher] Running 1 instances of WebDriver
[launcher] Error: TypeError: Target browser must be a string, but is <object>; did you forget to call forBrowser()?
My protractorConfig.js looks like:
/* global exports */
/* global process */
exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
capabilities: {
appiumVersion: "1.0",
app: "sauce-storage:app.zip",
platformName: "iOS",
platformVersion: "7.1",
deviceName: "iPhone Simulator"
},
allScriptsTimeout: 30000,
specs: [
"spec/feature/*.js"
]
};
I should have read the docs more carefully. Appium's documentation for Desired Capabilities says that 'browserName' should be an empty string if you're not targeting a browser.
Updating my protractorConfig accordingly fixes the issue.
/* global exports */
/* global process */
exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
capabilities: {
appiumVersion: "1.0",
app: "sauce-storage:app.zip",
platformName: "iOS",
platformVersion: "7.1",
deviceName: "iPhone Simulator",
browserName: ""
},
allScriptsTimeout: 30000,
specs: [
"spec/feature/*.js"
]
};
Try adding of 'browserName': 'chrome' into your capabilities.

Activating chrome language flags when activating from protractor (selenium)

I'm writing end to end tests with Protractor for an angular website.
We have to support certain languages so I would like to init chrome using the --lang flag and start it with some other language. I searched the web and couldn't find any example to how it can be done.
My only lead was some article I saw and understood that I need to add to Protractor config file the "capabilities" section and there I can define the "args" property.
Then tried to tinker with it but no luck.
Any help will be most welcome.
Thanks,
Alon
How to set Browser language and/or Accept-Language header
exports.config = {
capabilities: {
browserName: 'chrome',
chromeOptions: {
// How to set browser language (menus & so on)
args: [ 'lang=fr-FR' ],
// How to set Accept-Language header
prefs: {
intl: { accept_languages: "fr-FR" },
},
},
},
};
More examples:
intl: { accept_languages: "es-AR" }
intl: { accept_languages: "de-DE,de" }
As it turns out - the answer was in the docs all along.
This is how you do it for chrome and i guess it similar for other browsers:
inside the protractor.conf.js (for Spanish):
capabilities: {
browserName: 'chrome',
version: '',
platform: 'ANY',
'chromeOptions': {
'args': ['lang=es-ES']}
}

Resources