Headless chrome: chrome not reachable - angularjs

I am using Chrome headless to run the protractor test. It runs for a while but after that i get the following error.
[15:36:30] E/launcher - chrome not reachable (Session info:
headless chrome=59.0.3071.115) (Driver info:
chromedriver=2.30.477690
(c53f4ad87510ee97b5c3425a14c0e79780cdf262),platform=Mac OS X 10.11.6
x86_64) (WARNING: The server did not provide any stacktrace
information) Command duration or timeout: 5 milliseconds Build info:
version: '3.4.0', revision: 'unknown', time: 'unknown'
The configuration is as shown below.
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['headless', 'disable-gpu']
}
Tests run fine when i run without the 'headless' args.

Update capabilities as it shows in the official manual:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu"]
}
}
You could take a look at Using headless Chrome section

Related

Protractor acting randomly or occasionally not starting

I've been tasked with writing different suites of tests and tasks automation but Protractor has been acting in a very strange way the past couple days and... I just don't recall having changed anything from the last time my suites ran correctly.
Currently using the latest drivers:
% ./node_modules/webdriver-manager/bin/webdriver-manager status
webdriver-manager: using local installed version 12.1.0
[09:14:25] I/status - selenium standalone version available: 3.13.0 [last]
[09:14:25] I/status - chromedriver version available: 2.40 [last]
[09:14:25] I/status - geckodriver version available: v0.21.0 [last]
[09:14:25] I/status - android-sdk is not present
[09:14:25] I/status - appium is not present
And what appears to be the latest Protractor version:
% ./node_modules/protractor/bin/protractor --version
Version 5.3.2
This is what Protractor's output looks like 80% of the time, when it doesn't run:
% ./node_modules/protractor/bin/protractor ./conf.js --suite scenarios --params.login.usr=$USR_E2E --params.login.pwd=$PWD_E2E --params.env=test
(node:1709) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[09:03:07] W/driverProviders - Using driver provider hosted, but also found extra driver provider parameter(s): seleniumServerJar
[09:03:07] I/launcher - Running 1 instances of WebDriver
[09:03:07] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[09:03:08] E/launcher - Error: NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"[type="email"]"}
(Session info: headless chrome=67.0.3396.99)
(Driver info: chromedriver=2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363),platform=Mac OS X 10.14.0 x86_64)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[09:03:08] E/launcher - Process exited with error code 100
The corresponding webdriver-manager's output:
% ./node_modules/webdriver-manager/bin/webdriver-manager start
webdriver-manager: using local installed version 12.1.0
[09:30:49] I/start - java -Dwebdriver.chrome.driver=/Users/cyril/Projects/parkopoly_e2e/node_modules/webdriver-manager/selenium/chromedriver_2.40 -Dwebdriver.gecko.driver=/Users/cyril/Projects/parkopoly_e2e/node_modules/webdriver-manager/selenium/geckodriver-v0.21.0 -jar /Users/cyril/Projects/parkopoly_e2e/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.13.0.jar -port 4444
[09:30:49] I/start - seleniumProcess.pid: 1791
09:30:49.534 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.13.0', revision: '2f0d292'
09:30:49.535 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-07-16 09:30:49.613:INFO::main: Logging initialized #282ms to org.seleniumhq.jetty9.util.log.StdErrLog
09:30:49.752 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
09:30:55.414 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--disable-extensions",
"--show-fps-counter=true",
"--disable-infobars",
"--incognito",
"--disable-gpu",
"--headless"
]
},
"count": 1
}
09:30:55.415 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363) on port 24866
Only local connections are allowed.
09:30:55.951 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:30:56.171 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 9ea12201cba04ac9e41639501f0c02e1 (org.openqa.selenium.chrome.ChromeDriverService)
09:30:56.925 INFO [ActiveSessions$1.onStop] - Removing session 9ea12201cba04ac9e41639501f0c02e1 (org.openqa.selenium.chrome.ChromeDriverService)
Here's the conf.js file I'm currently using:
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
SELENIUM_PROMISE_MANAGER: false,
rootElement: 'html',
seleniumServerJar: './bin/selenium-server-standalone-3.12.0.jar',
seleniumPort: '4444',
seleniumAddress: 'http://localhost:4444/wd/hub',
framework: 'jasmine2',
directConnect: false,
specs: ['./e2e/**/*.spec.js'],
suites: {
cft: './e2e/cft/**/*.spec.js',
scenarios: './e2e/scenarios/**/*.scenario.js'
},
jasmineNodeOpts: {
isVerbose: true,
defaultTimeoutInterval: 15000,
print: function() {}
},
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--disable-extensions', '--show-fps-counter=true', '--disable-infobars', '--incognito', '--disable-gpu', '--headless']
}
},
onPrepare: async function() {
browser.params.ts = Date.now();
if (browser.params.env === undefined)
browser.params.env = 'test';
await jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStackTrace: true,
displaySuccessful: true,
displayFailed: true,
displayPending: true,
displaySpecDuration: true,
displaySuiteNumber: true
},
summary: {
displayFailures: true,
displayPending: false
},
colors: {
enabled: true,
successful: 'green',
failed: 'red',
pending: 'yellow'
}
}));
await browser.get('https://dashboard-' + browser.params.env + '.website.com');
await browser.driver.findElement(by.css('[type="email"]')).sendKeys(browser.params.login.usr);
await browser.driver.findElement(by.css('[type="password"]')).sendKeys(browser.params.login.pwd);
await browser.driver.findElement(by.css('[type="submit"]')).click();
return await browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /calendar_bo/.test(url);
});
}, 10000);
}
};
Sometimes, whenever Protractor starts and launch the tests, it just suffers from race conditions.
I couldn't find any thread, post, comment or anyone that ever had such outputs. I'm running out of ideas and I'd appreciate any ideas or potential solutions. Thanks!
Have not enough reputation to comment..
Could it be that you have a seleniumServerJar AND a seleniumAddress configured at the same time? Documentation specifies to use only 1.
Protractor needs to know how to connect to Drivers for the browsers it
is testing on. This is usually done through a Selenium Server.
There are five options - specify one of the following:
seleniumServerJar - to start a standalone Selenium Server locally.
seleniumAddress - to connect to a Selenium Server which is already running.
sauceUser/sauceKey - to use remote Selenium Servers via Sauce Labs.
browserstackUser/browserstackKey - to use remote Selenium Servers via BrowserStack.
directConnect - to connect directly to the browser Drivers. This option is only available for Firefox and Chrome.
can you try this code before email send keys:
var EC = protractor.ExpectedConditions;
var email_element = element(by.css('[type="email"]'));
browser.wait(EC.visibilityOf(email_element), 10000);

Protractor, internet explorer stops at "initial start page for the WebDriver server."

I have successfully created and executed test suites in Protractor for Chrome and Firefox. However I am unable to run tests with Internet Explorer. It stops at "initial start page for the WebDriver server" and displays this error in the powershell:
[11:02:10] I/launcher - Running 1 instances of WebDriver
[11:02:10] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[11:02:46] E/launcher -
[11:02:46] E/launcher - WebDriverError
at WebDriverError (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5)
at parseHttpResponse (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:521:11)
at doSend.then.response (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:777:24)
at createDriver (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:167:33)
at Builder.build (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:632:14)
at Hosted.getNewDriver (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.ts:60:29)
at Runner.createBrowser (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:225:39)
at q.then.then (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:391:27)
at _fulfilled (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
[11:02:46] E/launcher - Process exited with error code 199
This is my protractor config:
// Protractor configuration file
exports.config = {
seleniumAddress: "http://localhost:4444/wd/hub",
multiCapabilities: [
//{ browserName: "chrome" },
{
browserName: 'internet explorer',
}
//{ browserName: "firefox" }
],
framework: "jasmine2",
jasmineNodeOpts: {
defaultTimeoutInterval: 2500000,
showColors: true, // Use colors in the command line report.
isVerbose: true,
includeStackTrace: true
},
specs: [
"specs/login-spec.js",
],
resultJsonOutputFile: "./Report.json",
};
I read tens of posts on StackOverflow but didn't find any solusion to my problem. I have tried to change IE settings but they always go back to its defaults due to corporation setup.
The error stacktrace doesn't give my much information on what's wrong actually. I'm not very familiar with WebDriver source.
Any suggestions? Did anyone face similar problem?

Safari browser not invoking with protractor framework

I am trying to run test on Safari browser, it is working when run selenium server with selenium "selenium-server-standalone-2.47.1.jar" it working fine.
I have downloaded and installed safari webdriver driver extension.
Using Safari browser: 5.1.7 on window machine.
I added browser configuration in conf file:
'browserName': 'safari'"
When I am running server with
webdriver-manager start
Getting below exception and safari browser not launched.
:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-
webdriver\error.js:27
super(opt_error);
^
WebDriverError: The best matching driver provider org.openqa.selenium.ie.InternetExplorerDriver can't create a new driver instance for Capabilities [{count=1, browserName=safari}]
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'Admin-PC', ip: '10.253.10.4', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: unknown at WebDriverError C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\error.js:27:10)
at Object.checkLegacyResponse (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\error.js:580:13)
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:64:13
at Promise.invokeCallback_ (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1329:14)
at TaskQueue.execute_ (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2790:14)
at TaskQueue.executeNext_ (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2773:21)
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2652:27
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7 at process._tickCallback (node.js:369:9)From: Task: WebDriver.createSession()
at acquireSession (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:62:22)
at Function.createSession (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\seleniu-webdriver\lib\webdriver.js:295:12) at Builder.build (C:\Users\Admin\AppData\R oaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:458:24)
at [object Object].DriverProvider.getNewDriver (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:42:27)
at [object Object].Runner.createBrowser (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\built\runner.js:203:37)
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\built\runner.js:293:21
at _fulfilled (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\Admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
Let me know what I am missing.
I belive you should use like this
multiCapabilities: [{
name: 'ChromeIphone',
logName: 'Chrome Iphone',
browserName: 'chrome',
chromeOptions: {
'args': ['user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A405 Safari/600.1.4']
},
mobileEmulationEnabled: true
}]
in your conf.js file cause protractor works on windows machine with chromium and you have to set user-agent parameter to show that your go to your page through safari browser. So you are not able to run Safari browser directly on windows machine only through chrome driver.

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
}];

Facing issue in running chrome browser on Selenium Grid

I am able to run my test cases on firefox browser on Selenium Grid, but I am having issues while running the tests on Chrome Browser, its kind of configuration issue it seems.
I am getting below error while running the tests:-
org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Linux 3.13.0-63-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 504 milliseconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
I am running my node with following command:-
export PATH=$PATH:/root/ChromeDriver
java -jar selenium-server-standalone-2.48.2.jar -port $1 -role node -hub http://localhost:4444/grid/register -timeout 1800000 -nodeConfig nodeconfig.json -Dwebdriver.chrome.driver="/root/ChromeDriver/chromedriver"
below is my nodeconfig.json
{
"capabilities":
[
{
"browserName": "firefox",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"configuration":
{
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": 127.0.0.1
}
}
I've added the binary path also using command:-
-Dwebdriver.chrome.driver="/root/ChromeDriver/chromedriver"
Can somebody suggest what am I doing wrong?
The error is not saying that it cannot find the "chromedriver" binary.
The error is telling you that Selenium could not find the location where Chrome browser itself was installed. Please check the PATH of chrome browser.

Resources