Protractor - Shard By Suite - selenium-webdriver

It looks like Protractor currently allows you to shard by file. Is there way to split it up by suite, if there are files within each suite that are order dependent (each suite being independent)?

This functionality might be achievable by setting multiple capabilities each with their own specs property containing only scripts from a particular suite.
Each capability would not be sharded so all tests in each capability would run in sequence but each capability would run parallel.
maxSessions:5 allows 5 capabilities to run at the same time
maxSessions: 5,
multiCapabilities: [
{
browserName: 'chrome',
maxInstances: 1,
specs: [
'../suite1/test1.js',
'../suite1/test2.js',
'...',
],
},
{
browserName: 'chrome',
maxInstances: 1,
specs: [
'../suite2/test1.js',
'../suite2/test2.js',
'...,'
],
},
]

Related

Protractor tests are not running in firefox with directconnect true

config file
I am unable to run my test in firefox with directconnect true. Please provide a solution
Versions:
Angular: 4
Protractor: 5.1.2
Selenium Standalone Server: 3.4.0
GeckoDriver: 0.18.0
Firefox Browser: 54.0
I modified your configuration file and use it as given below
exports.config =
{
framework: 'jasmine',
directConnect:true,
specs: ['spec4.js'],
capabilities: {
browserName: 'firefox',
}
};

Protractor+Typescript : Selenium Grid

How can we configure the selenium grid in protractor?
Do we need to create hub and node like how we do with selenium?
How can we run the "webdriver-manager" as hub/node?
Thanks
Harsh
Try the below configuration,
multiCapabilities: [
{
browserName: 'chrome',
seleniumAddress : "http://remotemachine1:4444/wd/hub"
},
{
browserName: 'firefox',
seleniumAddress : "http://remotemachine2:4444/wd/hub"
}
].
Before executing the test you need to start the selenium server using webdriver-manger start on both the remote machines.

Selenium 3.0 does not run on firefox on the grid

When I run my scripts using Selenium 3.0 on the grid, only firefox instances open and nothing happens.
My setup is like this:
Selenium - 3.0.0
Selenium Grid - hub and node started using Selenium 3.0.0 and with below options:
hub -
java -jar selenium-server-standalone.jar -role hub -timeout 300000
node -
java -Dwebdriver.gecko.driver=C:\Grid2\geckodriver-v0.11.1-win64\geckodriver.exe -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register -port 5556 -nodeConfig se2config.txt
se2config.txt contents -
{
"capabilities":
[
{
"browserName": "firefox",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "chrome",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "internet explorer",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5556,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
Firefox version - 47.0.2
Added geckodriver.exe path to PATH variable and also in the code using:
System.setProperty("webdriver.gecko.driver","<path>")
The scripts run fine locally, but when run on the grid, it just launches the firefox browser and does not do anything.
Following are the node logs:
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:135)
... 14 more
02:22:31.173 WARN - Exception: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#268c4f21, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#268c4f21, version=, platform=ANY, firefox_profile=UEsDBBQACAgIAIx2eUkAAAAAAAAAA...}], required capabilities = Capabilities [{}]
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:16 -0700'
The scr
I run the scripts from my local system and it gets executed on the grid node.
1.So what other changes or additions do I make to run tests on the grid.
2.Also, if I were to run my tests using jenkins, so since the code will be built on the jenkins node, how can I set the -Dwebdriver path for node, does it have to be the path of geckodriver on the jenkins slave or of that of the grid node.

Protractor fails with multiCapabilities but passes when only one test runs

I am having an issue running a test with 'multiCapabilities'. My multiCapabilities config is:
multiCapabilities: [{
browserName: 'chrome',
'name': 'LMB Decision Engine - UI Automation',
'tunnel-identifier': 'nonprod',
'parent-tunnel': 'LMSauceLabs'
}, {
browserName: 'chrome',
'name': 'LMB Decision Engine - UI Automation',
'tunnel-identifier': 'nonprod',
'parent-tunnel': 'LMSauceLabs'
}],
And the response that I get is:
[chrome #2] Failed: stale element reference: element is not attached to the page document
[chrome #2] (Session info: chrome=47.0.2526.73)
[chrome #2] (Driver info: chromedriver=2.20.353141 (da3cb4b52d3a04ce079546eac4dc96182f58602b),platform=Linux 3.13.0-32-generic x86)
However, when I run with this capabilities config it passes:
capabilities : {
'browserName': 'firefox',
'name': 'LMB Decision Engine - UI Automation',
'tunnel-identifier': 'nonprod',
'parent-tunnel': 'LMSauceLabs'
},
Has anyone seen this issue when running in parallel? I've tried all different combinations of browser, and disabling all of the plugins individually to see if they are incompatible with multiCapabilities, but the issue seems to be solely running in parallel version individually.
Thanks,
Tyler
If you are trying to run parallel tests in chrome you could use shardTestFiles:true in the multi capabilities config, like this:
multiCapabilities: [
{
browserName: 'chrome',
shardTestFiles: true,
// change this to the number of instances you want to run
maxInstances:2
}];

Angular Protractor with BrowserStack behind a proxy

I want to build a Testsuite for an Angular App. The testsuite should use the framework "Protractor".
When I start the testsuite local with protractor local.config.js, then the test are running successful.
When I start the testsuite with BrowserStack without proxy, also everything are okay.
Now my question:
What settings do I have to do if I want to perform the test by local browser stack behind a proxy?
Main BrowserStack configuration:
var
proxy = 'http://proxy.example.com:8888';
exports.config = {
capabilities: {
project: 'BrowserStack (beyond Proxy)',
proxy: {
proxyType: 'manual',
httpProxy: proxy,
sslProxy: proxy,
},
loggingPrefs: {
driver: "FINE",
server: "OFF",
browser: "FINE"
},
'browserstack.user': 'USER_KEY',
'browserstack.key': 'ACCESS_KEY', // show on BrowserStack
// Needed for testing localhost
'browserstack.local' : 'true',
// Settings for the browser you want to test
// (check docs for difference between `browser` and `browserName`
'browserName' : 'chrome',
'version' : '43.0',
'os' : 'OS X',
'os_version' : 'Yosemite',
'resolution' : '1024x768'
},
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
specs: [
'test/e2e/**/*.spec.js'
]
};
I call the script "BrowserStackLocal" with this parameters:
./BrowserStackLocal -v -proxyHost PROXY_DOMAIN -proxyPort PROXY_PORT $ACCESS_KEY localhost,$PORT,0
Stepts:
start the application on my local computer node app.js
start the script "BrowserStackLocal"
start the protractor with the browserstack configuration from above.
When you are behind a proxy server, you need to do two things:
If you are testing your local server, you need to setup the Local Testing connection by passing the proxy details, which I assume you are doing.
You have to make sure the Selenium requests made via Protractor also reach BrowserStack. The easiest option would be to use global-tunnel npm package. If your proxy is behind an Authentication, you can try using the tunnel npm module.
You no longer need to use global-tunnel. There is now a new configuration option webDriverProxy:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
webDriverProxy: 'http://127.0.0.1:8888',
capabilities: {
browserName: 'chrome'
},
specs: ['*.spec.js'],
};

Resources