Protractor Unable to execute test cases in Chome using webdriver-manager - protractor

Protractor is unable to start test cases in chrome browser using webdriver-manager.
I followed the instructions given here https://www.protractortest.org/#/
and faced the below error.
debarnab#debarnab-Aspire-A515-51G:~/ProtractorConnectionTesting$ protractor conf.js
[19:33:57] I/launcher - Running 1 instances of WebDriver
[19:33:57] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[19:33:57] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-45-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 59 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'debarnab-Aspire-A515-51G', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-45-generic', java.version: '1.8.0_201'
Driver info: driver.version: unknown
[19:33:57] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-45-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 59 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'debarnab-Aspire-A515-51G', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-45-generic', java.version: '1.8.0_201'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:761:15)
at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:626:16)
at Hosted.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
[19:33:57] E/launcher - Process exited with error code 199
conf.ts file
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js']
};
spec file
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
I am using Ubutu machine and trying to run a basic scenario. Selenium Server seems to be up and running in http://localhost:4444/, as mentioned. Can any one please suggest ?

Make your config as below
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['example_spec.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
Run npm i webdriver-manager & webdriver-manager update from your project folder.
if you get No Update config found error when trying to run the test run node node_modules/protractor/bin/webdriver-manager update
Now run your test
Hope it helps you

From this answer it appears that you can add --disable-dev-shm-usage when running on Linux machines to resolve this issue.
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js'],
capabilities: [
{
browserName: 'chrome',
chromeOptions: { args: ["--disable-dev-shm-usage"] },
},
};
Can you give this a try and let me know if it works? Thanks

Try running your job using the following chrome arg:
--capabilities.chromeOptions.args="no-sandbox"

Related

IE intstances is not working with protractor e2e

I have version :-
protractor 5.4.2
webdriver-manager version is 12.1.7
angular 7.2.4
Steps to run our app on IE:
run webdriver-manager update --ie
IEdriverserver.exe is 3.150.1 ,
standalone service is 3.14.59 jar
geckodriver-v0.26.0.exe
chromedriver_79.0.3945.36.zip
run webdriver-manager start --ie
open another terminal and run ng e2e
the error was:
Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
i 「wdm」: Compiled successfully.
[12:05:28] I/launcher - Running 1 instances of WebDriver
[12:05:28] I/local - Starting selenium standalone server...
[12:05:29] I/local - Selenium standalone server started at http://10.154.204.250:52076/wd/hub
[12:05:29] E/launcher - Unable to create new service: InternetExplorerDriverService
os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: driver.version: unknown
[12:05:29] E/launcher - SessionNotCreatedError: Unable to create new service: InternetExplorerDriverService
can you help me why I am receiving this error and how I can fix this?

I am running protractor on a chromebook : the error message tells me error:cannot find Chrome Binary?

While attempting to run protractor i get an error where it cant find chrome binary. Its a chromebook so the binary should already exist right?
why am i getting this error ?
Been looking around there doesnt seem to be any info.
[23:57:28] I/launcher - Running 1 instances of WebDriver
[23:57:28] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[23:57:29] E/launcher - unknown error: cannot find Chrome binary
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'penguin', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.44-04933-g0fb17cd4e23f', java.version: '11.0.4'
Driver info: driver.version: unknown
remote stacktrace: #0 0x5bad641316e9 <unknown>
[23:57:29] E/launcher - WebDriverError: unknown error: cannot find Chrome binary
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'penguin', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.44-04933-g0fb17cd4e23f', java.version: '11.0.4'
Driver info: driver.version: unknown
remote stacktrace: #0 0x5bad641316e9 <unknown>
at Object.checkLegacyResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:761:15)
at createDriver (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:626:16)
at Hosted.getNewDriver (/usr/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (/usr/lib/node_modules/protractor/built/runner.js:195:43)
at q.then.then (/usr/lib/node_modules/protractor/built/runner.js:339:29)
at _fulfilled (/usr/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at /usr/lib/node_modules/protractor/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/usr/lib/node_modules/protractor/node_modules/q/q.js:796:13)
[23:57:29] E/launcher - Process exited with error code 199
It is looking for chrome browser to run the test. In windows and Mac , if you have chrome browser version, which you are passing in protractor capability, installed in your system, then test run on it by default.
But You can set the chrome binary path as desired also by adding below property in your protractor.conf.js file
"chromeOptions": {
binary: 'Path_to_Chrome_binaries',
args: [],
extensions: [],
}
Note, binary: 'Path_to_Chrome_binaries' , here 'Path_to_Chrome_binaries' should be the path to Chrome.exe
You also need to make sure the webdriver-manager version is compatible with the chrome browser you are using to tun your test upon.
If this does not solves your issue then please provide the protractor.conf.js file while will help in answering rh2 question/debughing the issue.

Unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.34.522913

I am trying to run Protractor tests on centOS with headless chrome.
When I run the tests with "protractor conf.js" the system throws strange error:
[root#stage conf]# protractor conf.js
[10:17:16] I/launcher - Running 1 instances of WebDriver
[10:17:16] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[10:18:18] E/launcher - unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 3.10.0-6 93.5.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.12 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'stage', ip: '10.10.19.203', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693 .5.2.el7.x86_64', java.version: '1.8.0_151'
Driver info: driver.version: unknown
[10:18:18] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 3.10.0-6 93.5.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.12 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'stage', ip: '10.10.19.203', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693 .5.2.el7.x86_64', java.version: '1.8.0_151'
Driver info: driver.version: unknown
at WebDriverError (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/err or.js:546:15)
at parseHttpResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509: 13)
at doSend.then.response (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:4 41:30)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriv er.js:769:24)
at Function.createSession (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:7 61:15)
at createDriver (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:626:16)
at Hosted.getNewDriver (/usr/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (/usr/lib/node_modules/protractor/built/runner.js:195:43)
at q.then.then (/usr/lib/node_modules/protractor/built/runner.js:339:29)
at _fulfilled (/usr/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/usr/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/usr/lib/node_modules/protractor/node_modules/q/q.js:796:13)
[10:18:18] E/launcher - Process exited with error code 199
I am using:
Chromedriver v 2.34.522913,
CentOS Linux release 7.4.1708 (Core),
Protractor Version 5.2.0
I believe that this might be CentosOS issue with chrome.
If i would be you - i would check if chrome is actually installed normally: https://www.tecmint.com/install-google-chrome-on-redhat-centos-fedora-linux/
And also you might consider using Chromium instead Chrome, since i heard that Chrome might not work well on CentosOS:
https://www.hiroom2.com/2017/08/11/centos-7-chromium-en/
Chromedriver would be same for Chrome and Chromium
Another option might be to run Chrome in Docker Container

Protractor: setSize() failing with "WebDriverError: disconnected: unable to connect to renderer"

Starting October 18th upon upgrading to Chrome 62 my protractor suite started failing with:
WebDriverError: disconnected: unable to connect to renderer
when I called
WebDriver.manage().window().setSize(1280, 1480)
Full stack trace:
Stack Trace:
Running "protractor:default" (protractor) task
[10:48:23] I/launcher - Running 1 instances of WebDriver
[10:48:23] I/direct - Using ChromeDriver directly...
protractor startup failure: WebDriverError: disconnected: unable to connect to renderer
(Session info: chrome=62.0.3202.62)
(Driver info: chromedriver=2.32.498537 (cb2f855cbc7b82e20387eaf9a43f6b99b6105061),platform=Mac OS X 10.12.6 x86_64)
[10:48:24] E/launcher - Error: WebDriverError: disconnected: unable to connect to renderer
(Session info: chrome=62.0.3202.62)
(Driver info: chromedriver=2.32.498537 (cb2f855cbc7b82e20387eaf9a43f6b99b6105061),platform=Mac OS X 10.12.6 x86_64)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.manage().window().setSize(1280, 1480)
at setWindowDimensions (/Users/kyle/projects/c/web/build/config/protractor-conf.js:95:43)
at onPrepare (/Users/kyle/projects/c/web/build/config/protractor-conf.js:71:12)
at Function.promise (/Users/kyle/projects/c/web/node_modules/q/q.js:682:9)
at _fulfilled (/Users/kyle/projects/c/web/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/kyle/projects/c/web/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/kyle/projects/c/web/node_modules/q/q.js:796:13)
at /Users/kyle/projects/c/web/node_modules/q/q.js:556:49
at runSingle (/Users/kyle/projects/c/web/node_modules/q/q.js:137:13)
at flush (/Users/kyle/projects/c/web/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[10:48:24] E/launcher - Process exited with error code 100
Env Info:
ChromeDriver: chromedriver=2.32.498537 (cb2f855cbc7b82e20387eaf9a43f6b99b6105061), platform=Mac OS X 10.12.6 x86_64
Chrome : 62.0.3202.62
Protractor: 5.1.2 (connecting directly to chromedriver)
Node: v6.9.5
Upgrading to chromedriver 2.33 fixed my issue.
To specify a version when running webdriver-manager :
webdriver-manager update --versions.chrome 2.33

Finding elements with css selector == #linkreturned an unexpected error

I'm getting this error when running a file with protractor:
$ ./protractor config.js
Using the selenium server at http://ie11.dev:4444/wd/hub
[launcher] Running 1 instances of WebDriver
F
Failures:
1) test a simple mouseMove() it should show a popup
Message:
UnknownError: Finding elements with css selector == #linkreturned an unexpected error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 301 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'WIN-A0RAN2MRA9O', ip: '172.16.196.133', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:33476/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: d59ae082-5864-4734-9df1-5f0dff04bb7b
Stacktrace:
UnknownError: Finding elements with css selector == #linkreturned an unexpected error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 301 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'WIN-A0RAN2MRA9O', ip: '172.16.196.133', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:33476/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: d59ae082-5864-4734-9df1-5f0dff04bb7b
==== async task ====
WebDriver.findElements(By.cssSelector("#link"))
==== async task ====
Asynchronous test function: it()
Error
at [object Object].<anonymous> (/home/xxxxxxxxxxxx/protractortest/test.js:6:25)
Error
at [object Object].<anonymous> (/home/xxxxxxxxxxxx/protractortest/test.js:2:3)
at Object.<anonymous> (/home/xxxxxxxxxxxx/protractortest/test.js:1:63)
Finished in 2.04 seconds
1 test, 1 assertion, 1 failure
[launcher] 0 instance(s) of WebDriver still running
[launcher] internet explorer11 #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
test.js
describe('test a simple mouseMove()', function() {
it('it should show a popup', function() {
browser.ignoreSynchronization = true;
browser.driver.get('file:///C:/Users/xxxxxxxx/Documents/protractortest/index.html');
browser.sleep(1000);
expect($("#link").isDisplayed()).toBeTruthy();
// expect(element(by.id("link")).isDisplayed()).toBeTruthy();
// browser.actions().mouseMove(element(by.id("link"))).perform();
// browser.sleep(5000);
// expect($("#hover-div").isDisplayed()).toBeTruthy();
});
});
index.html
http://pastie.org/private/mm4xedyqsw0vrpmm5gqwiw
Selenium: 2.44
Protractor: 1.7.0
VM with IE11 and Win7
The whole purpose of this test is to check if mouseMove() works under IE11. But I'm not being able to select an element.
By the way, IE11 works well in another project, so there's something in the configuration that I'm probably missing in this example. But the other project is too complex and it has a really big configuration.
I think the problem was that I was using the file:// protocol. I changed to http:// (installing Apache, etc. on my host machine and accessing that from the VM) and it worked. I guess this was because some kind of security setting in IE 11. I'd wished a more descriptive error.