I want to take Selenium captures on Azure Pipelines - selenium

I want to take Selenium captures on Azure Pipelines
I want to get a capture as a confirmation of the test results.
But it can't be done.
Configuration values for Webdriver.io
maxInstances: 5,
browserName: 'chrome',
acceptInsecureCerts: true,
'goog:chromeOptions': {
args: [
'--no-sandbox',
'--disable-infobars',
'--headless',
'--disable-gpu',
'--window-size=1440,735'
],
}
Azure Pipelines configuration values
vmImage: ubuntu-latest
Package Version
"#wdio/cli":"^7.12.6",
"chromedriver": "^98.0.1",
The test result is a success, and the test itself is running.
However, the content of the acquired capture is blank.
What is the cause?

Related

Can I run Nightwatch js in paralell with a different env per worker?

I'm currently using Nightwatch js to run my E2E tests in paralell.
The issue I'm having is that my tests share the same database, which is causing me problems with shared data being rewritten across different tests/workers, resulting in flaky tests.
I thought about running each test worker with its own database, but I'm not sure how to do it in practice. My starting point would be having different settings for the test databases, each on a night-watch env which can be accessed by the individual workers, but so far I've not found if this would be possible.
Any ideas?
Yes you can run different tests on different workers, Nightwatch provides a way to do that. I have done something very similar where I ran the same test on three different browsers parallely.
You have to add the test_Worker configuration, which allows the tests to be run in parallel. When this is enabled the test runner will launch a configurable number of child processes and then distribute the loaded tests over to run in parallel.
The workers option configures how many child processes can run concurrently.
a) “auto” – determined by the number of CPUs e.g. 4 CPUs means 4 workers
b) {number} – specifies an exact number of workers
test_workers: {
enabled: true,
workers: 'auto'
}
This is how my Nightwatch.conf.js file looks like:
{
module.exports = {
src_folders: ["tests"],
test_settings: {
default: {
desiredCapabilities: {
browserName: 'chrome'
},
webdriver: {
start_process: true,
port: 4444,
server_path: require('chromedriver').path,
}
},
test_workers: {
enabled: true,
workers: 'auto'
},
safari: {
desiredCapabilities: {
browserName: 'safari',
alwaysMatch: {
acceptInsecureCerts: false
}
},
webdriver: {
port: 4445,
start_process: true,
server_path: '/usr/bin/safaridriver'
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox'
},
webdriver: {
start_process: true,
port: 4446,
server_path: require('geckodriver').path
}
}
}
}
Now to execute the test I use the command:
npx nightwatch tests/TC001_WikiSearch.js -e default,firefox,safari
Referenced from: https://testersdock.com/execute-parallel-tests-nightwatchjs/

How to skip protractor+jasmine tests specific to browsers

Assume that I've automated 25 tests and executing in multiple browsers like chrome, firefox, IE, Edge & Safari. All tests (25) are executing well on Chrome. In Firefox, Only 20 tests are running fine due to few protractor APIs are not supported. Similarly IE can execute only 23 tests.
I would like to skip the test only for browsers, which are not supported for particular test? Is there any way available?
You can create protracotr.conf file for each browser with specific suites where will be specified what tests should run. And execute in one time all protractor.conf files.
//protractor.chrome.conf
export let config: Config = {
...
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 1
},
SELENIUM_PROMISE_MANAGER: false,
specs: [
'../test/chrome/**/*.js'
]
};
and
//protractor.ie.conf
export let config: Config = {
...
capabilities: {
browserName: 'internet explorer',
shardTestFiles: true,
maxInstances: 1
},
SELENIUM_PROMISE_MANAGER: false,
specs: [
'../test/ie/**/*.js'
]
};
in your package.json:
{
...
"scripts": {
"test:all": "npm run test:chrome && test:ie",
"test:chrome": "protractor ./config/protractor.chrome.conf.js",
"test:ie": "protractor ./config/protractor.ie.conf.js",
...
},
...
}
With jasmine2 you can filter tests using a regular expression. Maybe you can add something like #chrome, #ie to your tests and then only run those ones by passing the grep flag:
it('should do stuff #ie #chrome', function() {
...
});
Then run protractor passing the grep flag:
protractor conf.js --grep='#ie'

theintern calling /__intern/client.htm in URL

I want to run intern tests locally with selenium-standalone both of which i installed through npm.
when i go to run the tests -> "./node_modules/.bin/intern-runner" config=./pmictests/test/bit/GAT/internEx/intern
the browser starts but the url goes to http://localhost:8585/__intern/client.html?config=.%2Fpmictests%2Ftest%2Fbit%2FGAT%2FinternEx%2Fintern&basePath
As in the _intern/client.html? is not what i want
why is this happening? i'm trying to get my head around it but been stuck on this problem for a while.
my config file looks like this:
define({
proxyPort: 9515,
proxyUrl: 'http://localhost:8585/',
tunnel: 'NullTunnel',
useSauceConnect: false,
capabilities: {
'fixSessionCapabilities' : false,
'selenium-version': '2.35.0',
'idle-timeout': 36
},
environments: [
{ browserName: 'chrome' }
],
maxConcurrency: 3,
useSauceConnect: false,
webdriver: {
host: 'localhost',
port: 4444
},
suites: [ './tests/test/' ],
excludeInstrumentation: /^(?:tests|node_modules)\//
});
That URL is for running unit tests. When you run intern-runner, it automatically loads client.html to run any unit test suites listed in suites. Once the unit tests are finished, Intern runs any functional tests listed in functionalSuites (which will load their own URLs).

How to change browser language of webdriverio

I would like to change browser language. but it is not working. default browser language is displayed..
capabilities: [{
browserName: 'chrome',
chromeOptions: {
args: ['--lang=ja']
}
}],
If anyone is still interested in making this work, the WebdriverIO implementation would be:
capabilities: [{
browserName: 'chrome',
'goog:chromeOptions': {
args: [ '--your-args-go-here',
'--like-so',
'--and-so-and-so'
// e.g: '--headless', '--disable-gpu', '--start-fullscreen'
],
prefs: {
'intl.accept_languages': 'ru,RU'
}
}
}]
For the full list of Chromium switches (args array values), click here.
For the full list of Chromium preferences (prefs object properties), click here.
Note: another useful resource (which is always up to date) for Chromium switches is Peter Beverloo's Chromium CLI Switches portal.
Using the above Chrome config in the wdio.conf.js & running an Instagram login test will successfully convert the locale of the page to Russian, as seen below:
could you try this instead?
options = webdriver.ChromeOptions()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
driver = webdriver.Chrome(chrome_options=options)
check on webdriver io how to use add_experimental_option

How to use Browserstack's mobile device testing feature using protractor scripts?

I have written a spec and a config file that run using protractor and browserstack to test a website on different browsers. I am trying to utilize browserstack's mobile device testing feature by editing the config to test a device.
When protractor filename-conf is run the following error is returned.
"WebDriverError: Not yet implementd. Please help us: htttp://appium.io/get-involved.html"
Here is the config that attempts to run the spec on a mobile web browser.
exports.config = {
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
specs: [
'example-spec.js'
],
multiCapabilities: [{
browserName : 'iPhone',
'platform' : 'MAC',
'device' : 'iPhone 5S',
'deviceOrientation' : 'portait',
'project' : 'Isengard Mobile Automation',
'build' : 'Mobile Test',
'browserstack.user': 'username',
'browserstack.key': 'keyname',
acceptSslCerts: 'true'
directConnect: true
}],
Do I need appium to utilize browserstacks mobile testing?
BrowserStack uses Appium to drive your Selenium tests on iOS. The exception you received probably indicates a certain Selenium command you executed, is not supported yet by Appium.
You need NOT download Appium to run your Selenium scripts on BrowserStack's mobile testing platform. You simply have to change the capabilities (as you've done) and you should be good to go.
I would recommend reaching out to BrowserStack's Support (support#browserstack.com) as they would be the best guys to help you with this :)
Note: The capabilities you've mentioned for iOS are correct as given in BrowserStack's documentation here. You need not make any changes there.
Few changes required as also suggested in the comments to your capabilities -
multiCapabilities: [
{
platformName: 'iOS',
platformVersion: '7.1',
browserName: '',
app: '<your app name>',
deviceName: 'iPhone 5S',
'deviceOrientation' : 'portait',
'project' : 'Isengard Mobile Automation',
'build' : 'Mobile Test',
'appium-version': "1.4.0",
username: '<USERNAME>',
accessKey: '<KEY>',
acceptSslCerts: 'true',
directConnect: 'true'
}],