Protractor's browser.pause() pausing but shows no context - selenium-webdriver

I'm having trouble making Protractor's browser.pause() work. It pauses but it doesn't show the context. Is there any known issue about this?
The terminal output is just this:
$ protractor conf.js
[10:05:23] I/launcher - Running 1 instances of WebDriver
[10:05:23] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
[10:05:27] I/protractor -
[10:05:27] I/protractor - Encountered browser.pause(). Attaching debugger...
[10:05:27] I/protractor -
[10:05:27] I/protractor - ------- WebDriver Debugger -------
[10:05:27] I/protractor - Starting WebDriver debugger in a child process. Pause is still beta, please report issues at github.com/angular/protractor
[10:05:27] I/protractor -
[10:05:27] I/protractor - press c to continue to the next webdriver command
[10:05:27] I/protractor - press ^D to detach debugger and resume code execution
[10:05:27] I/protractor -
Starting debugger agent.
Debugger listening on [::]:5858
>>>
According to some images on internet it should show some more lines, the first one being "ControlFlow::", then like a trace up to the code snippet where it paused.
If I remove the pause it passes the test OK.
I'm using the simple example on the protractor tutorial (http://www.protractortest.org/#/tutorial) (adding just one line: browser.pause();):
// spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
browser.pause();
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
I tried in macOS Sierra and Ubuntu, and in both the situation is exactly the same. On macOS I tried with Chrome, Firefox and Safari (with the capabilities config attribute).
Versions:
Protractor version 5.1.1.
Chrome (version 56.0.2924.87, 64-bit).
Firefox (52.0)
Safari (10.0.3)
With Firefox the same happens when pausing (at the beginning of the test), and without pause it doesn't pass the test, it says the page doesn't have Angular (but it does):
[09:44:56] E/protractor - Could not find Angular on page http://juliemr.github.io/protractor-demo/ : retries looking for angular exceeded
With Safari it doesn't even connect (with or without the pause):
[09:40:00] I/launcher - Running 1 instances of WebDriver
[09:40:00] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[09:40:22] E/launcher - Connection refused
[09:40:22] E/launcher - WebDriverError: Connection refused
Any suggestion is welcome. Thanks in advance.

I was able to solve the wait by browser.sleep(5000)
Use - browser.sleep()

I finally found a way to run a repl. When browser.pause pauses, there's a repl command, but it doesn't work anymore:
Error: using repl from browser.pause() has been removed. Please use browser.enterRepl instead.
So following that message I change browser.pause(); with browser.enterRepl(); and then it stopped and gave me the context.
And there's another alias for enterRepl: browser.explore();
Hope it helps anyone having the same issue.

Related

OperaDriver for Selenium remains stuck when launching tests

I am using TestNG to run automated tests using a Selenium Java client. The tests are running fine on chrome and firefox but when I try to run the same on opera, I end up seeing tests timing out on the following console message:
Starting OperaDriver 2.35 (ee0117ea0f7f76009fd2aa3dd6b6164205de32b5) on port 27234
Only local connections are allowed.
org.openqa.selenium.WebDriverException:
unknown error: Opera failed to start: exited abnormally
(Driver info: OperaDriver=2.35 (ee0117ea0f7f76009fd2aa3dd6b6164205de32b5),platform=Linux 4.13.0-38-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Environment
Ubuntu 16.04LTS
JDK 10
Selenium 3.11.0
OperaDriver 2.35(downloaded from here)
Code
OperaOptions options = new OperaOptions();
options.setBinary("operadriver");
testDriver = new OperaDriver(options);
I am trying to understand what went wrong here.
Many in the community seem to get the same error when trying to get opera running with selenium and opera driver. I also tested this with your versions and get the same output, although the other browsers are working just fine.
Opera does not seem to put a lot of resources in making this work. Check out this link for some more information, it is actually a slightly different issue, but still there are some background informations there.
The suggested hack is to run opera through an appropriate version of the chromedriver. I also got opera running with selenium that way some time ago (therefore other versions), but I did not yet test this with your configuration.
Update
I managed to get the following configuration work:
Ubuntu 16.04
Java 1.8
Selenium 3.11.0
Operadriver 2.30
Opera 48.0.2685.52
by using the chrome hack and passing the operadriver as the "chrome"driver

not able to start nightwatch for testing WebRTC

I am new to selenium. Now, I am stumbled upon Nightwatch.js for testing WebRTC. I am trying out this link to start. Now I have set up accordingly. Now when I try to run, I am getting the following error
Starting selenium server... There was an error while starting the Selenium server:
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -host
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$1.setConfiguration(GridLauncherV3.java:219)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:147)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:73)
Following other links. I ran the following command
java -Dwebriver.chrome.driver="./bin/chromedriver" -jar bin/selenium-server-standalone-3.0.0.jar
And the selenium server started, but still when I run the test from Nightwatch, the error exists, Please help!

How to debug protractor in Intellij?

In OSX, I have configured an Intellij 15 run/debug task as in this question:
How to debug angular protractor tests in WebStorm
It runs ok but debug doesn't work. It throws:
/usr/local/bin/node --debug-brk=60144 --nolazy /usr/local/lib/node_modules/protractor/lib/cli.js /Users/XXXX/Workspace/frontend-test/config.js
Debugger listening on port 60144
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Process finished with exit code 139
Any idea?
Thanks in advance.
Got it! Just add --harmony parameter to "Node parameters" in the Run/Debug Configuration window.

browser.debugger() doesn't pause browser

I am using WebStorm 9 and Protractor version 1.8. I prefer to use Chrome (version 41.0.2) for my debugging and am able to able to debug the normal application in Browser and also in WebStorm.
However debugging Protractor is failing.
Protractor --version //1.8.0
Angular // 1.3
OS // Windows 7
Here is a simple test
it('check title', function () {
browser.get('/e2e/employeeForm.html');
browser.sleep(5000);
browser.debugger();
var title = element(by.className('someClass'));
expect(title.getText()).toMatch('Employee Form');
});
In terminal, in one console I started webdriver webdriver-manager start. In other, I ran the command
protractor debug prc.conf.js
Following is the output:
Starting debugger agent.
debugger listening on port 5858
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
connecting... ok
break in timers.js:79
77 }
78
79 function listOnTimeout() {
80 var msecs = this.msecs;
81 var list = this;
debug>
I hit c and Enter. It continues and all tests fails. Even browser doesn't render my page. browser.debugger() is ignored.
Can anyone suggest me anything here?
There is a bug with protractor 1.8.0 and windows detailed here: https://github.com/angular/protractor/issues/1822
The bug has been fixed in master (https://github.com/angular/protractor/pull/1850), and will be released in the next version of protractor.

Unable to run Protractor - ECONNREFUSED connect ECONNREFUSED

I'm trying to learn AngularJS. As part of this, I want to learn to use end-to-end testing. Currently, I have a directory structure like this:
node_modules
.bin
...
protractor
...
node_modules
.bin
adam-zip
glob
minijasminenode
optimist
saucelabs
selenium-webdriver
protractor
config.js
src
tests
test.e2e.js
My config.js file looks like the following:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: [
'../src/tests/test.e2e.js'
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
test.e2e.js looks like the following:
'use strict';
describe('My Sample', function () {
driver = protractor.getInstance();
beforeEach(function () {
driver.get('#/');
});
it('My First Test', function () {
message = "Hello.";
expect(message).toEqual('World.');
});
});
When I attempt to run my end-to-end tests using protractor, I run the following command from the command-line:
node_modules\.bin\protractor protractor\config.js
When I run that command, I receive the following error:
C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1542
throw error;
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:12
7:16)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1528:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriv
er\lib\webdriver\webdriver.js:130:49)
at Function.webdriver.WebDriver.createSession (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver
\lib\webdriver\webdriver.js:110:30)
at Builder.build (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\builder.js:105:20)
at runJasmineTests (C:\Src\MyProject\node_modules\protractor\lib\runner.js:191:45)
at C:\Src\MyProject\node_modules\protractor\lib\runner.js:255:5
at C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriv
er\lib\webdriver\promise.js:1438:20)
at notify (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:328:12)
at then (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:377:7)
What am I doing wrong?
I solved this with --standalone flag:
webdriver-manager start --standalone
I got it working by removing the following line from my config.js
seleniumAddress: 'http://localhost:4444/wd/hub',
Are you running a selenium server? The git README states the following:
WebdriverJS does not natively include the selenium server - you must start a standalone selenium server. All you need is the latest selenium-server-standalone.
source: https://github.com/angular/protractor
The error message is due to the following:
[ECONNREFUSED] The attempt to connect was ignored (because the target is not listening for connections) or explicitly rejected.
Check the URL of the Webdriver manager. The default URL is:
http://localhost:4444/wd/hub
Use a background process to run the webdriver-manager, then run protractor:
Start-Process webdriver-manager start -passthru
protractor conf.js
This will start up a Selenium Server and will output a bunch of info logs. Your Protractor test will send requests to this server to control a local browser. Leave this server running
References
Protractor Tutorial
Protractor Docs: Config File Reference
CONNECT Man Page
POSIX Man Page
For me, this had happened due to incompatible versions of Node and Protractor.
My fix-
Update Node to latest version (v7.0.0 in my case)
Follow steps given here https://stackoverflow.com/a/19333717/1902831
Install latest protractor version (4.0.10 in my case) using:
npm install -g protractor
Open another terminal and execute these command:
webdriver-manager update
webdriver-manager start
Run tests in another terminal using:
protractor conf.js
If you are using the npm protractor-webdriver grunt plugin (https://www.npmjs.org/package/grunt-protractor-webdriver) you may exeprience same kind of error.
This is due to webdriver termination just before test ends. The test runs successfully and then you have a message like :
Session deleted: Going to shut down the Selenium server
Shutting down Selenium server: http://127.0.0.1:4444
Shut down Selenium server: http://127.0.0.1:4444 (OKOK)
d:\Projets\Clouderial\nodeProjects\cld-apps\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (d:\Projets\Clouderial\nodeProjects\cld-apps\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145:16)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
I resolve this using the keepAlive option in the grunt plugin.
Here is my Gruntfile.js config :
protractor_webdriver: {
options: {
keepAlive : true // True to keep the webdriver alive
},
start: {
},
},
...
I hope this will help someone.
JM.
I also faced the same problem,the trick that worked for me is to use two cmd windows,keeping the one open after typing webdriver-manager start and without pressing enter key(if enter key is pressed the selenium server is shutdown,don't know why) open another cmd window and call your tests.
#Alexandros Spyropoulos, it took me quite some time to figure out how to run protractor and I think we had the same problem. You should open one terminal tab and run webdriver-manager start --standalone. Then open another terminal tag and run protractor ***.conf.js
In the hopes that it might help someone: I'd been having the same problem - encountering ECONNREFUSED using grunt-protractor-runner. The nuance to my case is that I was running my entire E2E environment (test files, web application and entire backend) within a Docker container.
I tried running protractor
with and without additional grunt-protractor-webdriver task to get webdriver up and running 'manually' (no difference);
with and without enabling directConnect and keepAlive settings (bypassing Selenium and resulting in crashes related to Chromedriver, one of which was described here).
The solution was rather simple: increase the amount of memory allocated to the container. On my Windows 10 host machine, I performed the following steps:
Run VBoxManage.exe modifyvm default --memory 8192 (via custom shell script) before starting the docker-machine (via Docker Quickstart script, which is equivalent to docker-machine start). (Thanks to this SO answer).
Changing my shell script to run my default container, adding the --shm-size=4G argument to my docker run command. (See docs)
You can verify if it worked by running df -h in your guest machine, by checking the amount of memory mounted on /dev/shm.
As a result, I no longer have seemingly inexplicable errors such as ECONNREFUSED.
If you run the provided protractor demo, you should try running the protractor config in the same command prompt as selenium. Try running both selenium server and protractor separately.
Make Sure first selenium runs by following command.
webdriver-manager start --standalone
And run the protractor in a separate command window.
protractor conf.js
(In my case conf.js was the config file )
I faced a similar issue to the one #David Remie faced with the Selenium Docker grid/standalone. With minimal RAM/CPU, the tests would start before the webdriver was up. A less resource consuming approach is to wait a few seconds before testing (run 'sleep 5' or something like that).
Increasing RAM was sometimes enough as a workaround for the issue, but the real problem was that the Selenium CMD (/opt/bin/entry_point.sh, starts a supervisor that runs the webdriver) from the image based on https://hub.docker.com/r/selenium/node-base/dockerfile was taking time to start the Selenium webdriver.
webdriver-manager start ----- didn't help, But below one helped
webdriver-manager start --standalone

Resources