Xvfb and Protractor produce Timeouts - selenium

I want to run protractor tests on a webserver integration platform without gui based on redhat linux. The tests will be executed whenever the webserver software will be deployed. I use firefox and geckodriver.
The call chain is
protractor calls
firefox on
Xvfb calls
(local) Webserver
and backwards to the caller.
I get Jasmine timeouts when starting Protractor with Xvfb.
My environment:
node: v12.14.1
npm: 6.14.2
Xvfb: ?, installed, callable
xvfb-run: ?, installed, callable
My start scripts:
Selenium:
java -jar -Dwebdriver.chrome.driver=/pathx/geckodriver-v0.26.0 /pathy/selenium-server-standalone-3.141.59.jar &
This is essentially what 'webdriver-manager start' does, but I cannot need the update ahead.
Xvfb:
xvfb-run --auto-servernum --server-args='-screen 0 1920x1200x24' -e xvfb.err firefox &
Protractor:
DISPLAY=:99 protractor --verbose --troubleshoot --logLevel=DEBUG protractor.conf.js
All I get is
[15:00:59] D/launcher - Running with --troubleshoot
[15:00:59] D/launcher - Protractor version: 5.4.3
[15:00:59] D/launcher - Your base url for tests is undefined
[15:00:59] I/launcher - Running 1 instances of WebDriver
[15:00:59] I/direct - Using FirefoxDriver directly...
[15:01:00] D/runner - WebDriver session successfully started with capabilities C apabilities {
map_: Map {
'acceptInsecureCerts' => false,
'browserName' => 'firefox',
'browserVersion' => '60.9.0',
'moz:accessibilityChecks' => false,
'moz:geckodriverVersion' => '0.26.0',
'moz:headless' => false,
'moz:processID' => 32246,
'moz:profile' => '/tmp/rust_mozprofileAz14ww',
'moz:useNonSpecCompliantPointerOrigin' => false,
'moz:webdriverClick' => true,
'pageLoadStrategy' => 'normal',
'platformName' => 'linux',
'platformVersion' => '3.10.0-957.el7.x86_64',
'rotatable' => false,
'timeouts' => { implicit: 0, pageLoad: 300000, script: 30000 }
}
}
[15:01:00] D/runner - Running with spec files /home/xgadvls/az-uss/frontend/e2e/ src/specs/login/login-spec.ts,/home/xgadvls/az-uss/frontend/e2e/src/specs/logout /logout-spec.ts
Started
undefined
F(node:32231) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
Failures:
1) Anmeldung Anmeldedate werden eingegeben
Message:
Failed: WebDriverError
Stack:
Error: Failed: WebDriverError
at /home/xgadvls/az-uss/node_modules/jasminewd2/index.js:64:48
...
How can I get a webdriver error when I haven't got it in my call chain?! What am I doing wrong? Can anybody help?

The problem was caused by an invalid certificate.
My way to the solution may be interesting.
I renamed the geckodriver-v0.26.0 (or so) to geckodriver.bin.
I made a script with the original geckodriver name and called in that script the bin version with -vv argument (very verbose) and redirected the output into a file (>myfile). It is important to pass all parameters ($#).
The next test informed me in the log file about the invalid certificate. This can be fixed by a parameter AcceptInsecureCerts for firefox. (I guess chrome as well)
Here we go.
I hope this helps anybody.

Related

Selenium Chrome Driver Nightmare (nodejs)

I'm trying to setup tests with NodeJS, Selenium & Jest. They work fine on my Mac but both a Windows and Linux install are failing with similar errors:
WITHOUT THE PATH EXPLICITLY SET
WebDriverError: unknown error: cannot find Chrome binary
at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:522:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:548:13)
at Executor.execute (node_modules/selenium-webdriver/lib/http.js:474:28)
WITH THE PATH EXPLICITLY SET
WebDriverError: unknown error: Chrome failed to start: exited
abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/local/bin/chromedriver is no longer running, so ChromeDriver is
assuming that Chrome has crashed.)
FWIW on a linux machine running chromedriver directly I get this:
Starting ChromeDriver 98.0.4758.80
(7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758#{#972})
on port 9515 Only local connections are allowed. Please see
https://chromedriver.chromium.org/security-considerations for
suggestions on keeping ChromeDriver safe. ChromeDriver was started
successfully.
Setting the path directly has not worked, using a globally installed (/usr/local/bin/chromedriver) binary and a local one node_modules/chromedriver/bin/chromedriver). None of the following options has made any difference:
.addArguments([
"--ignore-certificate-errors",
"--disable-extensions",
"--disable-popup-blocking",
"--enable-automation",
"--disable-dev-shm-usage",
"--no-sandbox",
"--headless",
"--log-path=/home/jsp/projects/proj/selenium/chrome.log",
"--append-log",
"--verbose",
"--enable-chrome-logs",
"--port=9222"
])
Enabling logging generated an empty chrome.log file. I tried simplifying and this is what I ended up with that again works on my Mac but not on the Linux test box.
const { Builder } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
let chromeTest = async () => {
let options = new chrome.Options()
.setChromeBinaryPath('/usr/local/bin/chromedriver')
.addArguments(["headless", "ignore-certificate-errors", "disable-dev-shm-usage", "no-sandbox"]);
let driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(options)
.build();
await driver.quit();
};
chromeTest();
Selenium: 4.1.1
ChromeDriver: 98.0.4758.80
Ubuntu 20.04.3
Any help would be greatly appreciated.

How to run successfully Protractor e2e test in Cloud Builders?

I'm setting up CI for our project that is in Angular. We are using Google Cloud Platform's Cloud Builder for CI. Everything is going smoothly, we can setup the environment, install packages via npm, build the project using angular-cli and deploy. But the problem is that our test cases (e2e) in Protractor keeps getting an error. What are we missing here?
This is for the Continuous Integration using Google Cloud Builders, we are running the protractor in headless mode, and using the puppeteer's chromium as the chrome's binary path
This is my protractor.conf.js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath()
exports.config = {
allScriptsTimeout: 1000000,
specs: [
'./e2e/*.e2e-spec.ts',
'../e2e/*.e2e-spec.ts'
],
capabilities: {
// browserName: 'chrome',
browserName: 'chrome',
chromeOptions: {
binary: process.env.CHROME_BIN,
args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--disable-setuid-sandbox']
}
},
// seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
// ignoreUncaughtExceptions: true,
directConnect: true,
},
};
This is the error we are getting in cloud builders
[11:24:12] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-1033-gcp x86_64)
[11:24:12] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

phantom JS configuration when used with InternJS

I want to use phantomJS with Intern for functional testing.
I Installed phantomJS and ran the command "phantomjs --webdriver 4444", it ran successfully.
Then tried to run intern-runner with the command "intern-runner config=tests/intern" -file tests/intern is shown at the end of the post-.
but i keep getting the error
intern-runner config=tests/intern
Listening on 0.0.0.0:9000
Tunnel started
Suite phantomjs on any platform FAILED
UnknownError: [POST http: //localhost:4444/wd/hub/session / {"desiredCapabilities":{"browserName":"phantomjs","name":"tests/intern","idle-timeout":60}}] An unknown server-side error occurred while processing the command.
on intern.
and the error
[ERROR - 2015-10-14T10:14:35.611Z] RouterReqHand - _handle.error - {"message":"{
\"headers\":{\"Connection\":\"close\",\"Host\":\"localhost:4444\",\"accept\":\"a
pplication/json,text/plain;q=0.9\",\"content-length\":\"91\",\"content-type\":\"
application/json;charset=UTF-8\",\"user-agent\":\"dojo/2.0.0-dev Node.js/4.1.2\"
},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"url\":\"/session\",\"urlParsed\"
:{\"anchor\":\"\",\"query\":\"\",\"file\":\"session\",\"directory\":\"/\",\"path
\":\"/session\",\"relative\":\"/session\",\"port\":\"\",\"host\":\"\",\"password
\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\"\",\"s
ource\":\"/session\",\"queryKey\":{},\"chunks\":[\"session\"]}}","name":"Missing
Command Parameter","line":85,"sourceId":65775352,"sourceURL":":/ghostdriver/req
uest_handlers/session_manager_request_handler.js","stack":"Missing Command Param
eter: {\"headers\":{\"Connection\":\"close\",\"Host\":\"localhost:4444\",\"accep
t\":\"application/json,text/plain;q=0.9\",\"content-length\":\"91\",\"content-ty
pe\":\"application/json;charset=UTF-8\",\"user-agent\":\"dojo/2.0.0-dev Node.js/
4.1.2\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"url\":\"/session\",\"urlP
arsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"session\",\"directory\":\"/\"
,\"path\":\"/session\",\"relative\":\"/session\",\"port\":\"\",\"host\":\"\",\"p
assword\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\
"\",\"source\":\"/session\",\"queryKey\":{},\"chunks\":[\"session\"]}}\n at :
/ghostdriver/request_handlers/session_manager_request_handler.js:85\n at :/gh
ostdriver/request_handlers/session_manager_request_handler.js:44\n at :/ghost
driver/request_handlers/router_request_handler.js:70","stackArray":[{"sourceURL"
:":/ghostdriver/request_handlers/session_manager_request_handler.js","line":85},
{"sourceURL":":/ghostdriver/request_handlers/session_manager_request_handler.js"
,"line":44},{"sourceURL":":/ghostdriver/request_handlers/router_request_handler.
js","line":70}]}
on phantomjs - this error appears after running the intern-runner-.
does anyone know what the problem is?.
p.s. I'm using phantomJS v.1.9.8
tests/intern :
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
environments: [
{ browserName: 'phantomjs' }
],
maxConcurrency: 3,
useSauceConnect: false,
loaders: {
'host-browser': 'node_modules/requirejs/require.js'
},
tunnel: 'NullTunnel',
functionalSuites: [ 'tests/functional/modetest' ],
});
PhantomJS 1 is ancient (it uses a version of WebKit from 2012) and not supported. You must use PhantomJS 2+ with Intern.

Protractor : ERROR - Unable to start a WebDriver session

I wrote test cases three months back at that time they worked fine now i want to run those test cases in another system so i did basic setup. When i try to run protractor test case now they are failing with 'Unable to start a WebDriver session'. I have tried so many solutions but they didn't work for me.
Here i am attaching my protractor.conf.js file and error details.
protractor.conf.js
'use strict';
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
baseUrl: 'http://localhost:' + (process.env.PORT || '3036'),
chromeOnly: true,
// To get the maximimum test screen size
onPrepare: function() {
browser.driver.manage().window().maximize();
},
// list of files / patterns to load in the browser
specs: [
'e2e/attributeSection/search_spec.js', 'e2e/attributeSection/create_spec.js',
'e2e/attributeSection/edit_spec.js', 'e2e/attribute/search_spec.js',
'e2e/attribute/create_spec.js', 'e2e/attribute/edit_spec.js',
'e2e/classification/search_spec.js', 'e2e/classification/create_spec.js',
'e2e/classification/edit_spec.js', 'e2e/classificationGroup/create_spec.js',
'e2e/classificationGroup/edit_spec.js'
],
exclude: [],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
binary: 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
args: [],
extensions: [],
}
},
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 60000
}
};
Error in console
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.
C:\Users\Cronj- 4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145:16)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1552:9)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:155:22)
at Function.webdriver.WebDriver.createSession (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:129:30)
at [object Object].Builder.build (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:416:22)
at [object Object].DriverProvider.getNewDriver (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.js:38:7)
at [object Object].Runner.createBrowser (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:180:37)
at C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:257:21
at _fulfilled (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:759:13)
Could anyone help me out? Thanks in advance
I believe the "chromeOnly" option got deprecated in v2.0.0.
chromeOnly: true,
This used to mean use "direct" mode without a selenium server. But since both firefox and chrome support direct mode, the property was renamed to "directConnect". So change that line to:
directConnect: true,
In this mode you don't need a selenium server, so you can drop the seleniumAddress property which is just confusing folks.
See https://github.com/angular/protractor/pull/1933/files
I ran webdriver-manager start in one command prompt and protractor in another command prompt then only test cases started running

Chrome not firing by default through the webdriver-manager

I'm a newbie in e2e tests with protractor and I've recently encountered an issue. When I try to run my test (which is basically the same one I found on the official protractor website), the server starts by using Firefox as a default browser. As I read, chrome supposed to be the one used by default.
16:17:24.345 INFO - Executing: [new session: Capabilities [{count=1, browserName=firefox}]])
16:17:24.345 INFO - Creating a new session for Capabilities [{count=1, browserName=firefox}]
16:17:27.305 INFO - Done: [new session: Capabilities [{count=1, browserName=firefox}]]
Due to the Firefox issue #1734, the test fails all the time
Failures:
1) angularjs homepage todo list should add a todo
Message:
timeout: timed out after 36000 msec waiting for spec to complete
Stacktrace:
undefined
Finished in 36.777 seconds
1 test, 1 assertion, 1 failure
So I added chrome as another browser to use into the configuration file
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
browserName: 'chrome'
},
specs: ['todo-spec.js'],
framework: 'jasmine'
};
Here's the test
todo-spec.js
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('http://angularjs.org');
element(by.model('todoText')).sendKeys('write a protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write a protractor test');
});
});
But it still does not work. What am I doing wrong here?
Thanks for your help!