Error on protractor: “Timed out waiting for the We

2019-05-17 06:02发布

问题:

I was executing my scripts on firefox and got one notification for Firefox upgrade which I closed. Started execution again but I'm getting error as below,

Rohits-MacBook-Pro:FFAutomation rohitgathibandhe$ /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/bin/protractor conf.js
Report destination:   target/screenshots/Report.html
Using FirefoxDriver directly...
[launcher] Running 1 instances of WebDriver

/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:83
      Error('Timed out waiting for the WebDriver server at ' + url));
      ^
Error: Timed out waiting for the WebDriver server at http://127.0.0.1:50636/hub
at Error (native)
at onError (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:83:11)
at Promise.invokeCallback_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
at TaskQueue.execute_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
at /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2652:27
at /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (node.js:406:9)
From: Task: WebDriver.createSession()
at acquireSession (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:62:22)
at Function.createSession (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:295:12)
at Driver (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/firefox/index.js:271:38)
at [object Object].DirectDriverProvider.getNewDriver (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/built/driverProviders/direct.js:76:16)
at [object Object].Runner.createBrowser (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/built/runner.js:203:37)
at /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/built/runner.js:293:21
at _fulfilled (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/q/q.js:556:49
[launcher] Process exited with error code 1

My config file is as below,

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');

var reporter = new HtmlScreenshotReporter({
  dest: 'target/screenshots',
  filename: 'Report.html',
  reportTitle: 'Execution Report',
  showSummary: true,
  showQuickLinks: true,
  pathBuilder: function(currentSpec, suites, browserCapabilities) {
  // will return chrome/your-spec-name.png
  return browserCapabilities.get('browserName') + '/' + currentSpec.fullName;
 }
 });

exports.config = {

directConnect: true,
//seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {'browserName': 'firefox'},
framework: 'jasmine',
specs: ['Login_spec2.js','Article_spec.js'],
allScriptsTimeout: 200000,
getPageTimeout: 200000,
jasmineNodeOpts: {
    defaultTimeoutInterval: 200000
},

 // Setup the report before any tests start
  beforeLaunch: function() {
    return new Promise(function(resolve){
    reporter.beforeLaunch(resolve);
  });
 },
  // Close the report after all tests finish
  afterLaunch: function(exitCode) {
   return new Promise(function(resolve){
    reporter.afterLaunch(resolve.bind(this, exitCode));
  });
},

onPrepare: function() {
    var width = 1300;
    var height = 1200;
    browser.driver.manage().window().setSize(width,height);
    jasmine.getEnv().addReporter(reporter);
    afterAll(function(done) {
        process.nextTick(done);
    })
 }

 };

Other details are: Other details are as below: protractor@3.2.2, nodeVersion: 4.2.4, npmVersion: 2.14.12, jasmine: 2.4.1, selenium-webdriver: 2.52.0, firefox: 47

Kindly help me with solution to this issue.

回答1:

You have to do the following to make it work:

  • upgrade protractor to the latest, currently 3.3.0, version which would also bring selenium-webdriver 2.53
  • downgrade firefox to version 46 and don't let it update for a while (there are compatibility issues)


回答2:

In my case it was the local firewall (iptables on Linux) that was very restrictive such that WebDriver could not contact the Selenium server hub at whatever TCP port.

To make it work I turned off the firewall. The long term solution was to adjust the firewall rules such that this type of connection is allowed.

If you want your scripts communicate directly with the Firefox|Chrome Driver (bypassing the Selenium server entirely) then try adding the directConnect: true in your protractor.conf.js



回答3:

I solved it by change the browser (use Chrome instead of Firefox).

In C:__projectWorkspace__\src\test\javascript\protractor.conf.js modify the entry

capabilities: {
    'browserName': 'firefox',

to

capabilities: {
    'browserName': 'chrome',

That wasn't enough. I had to change also the webBrowserDriver 'cause after the JHipster installation the 2.22 version was written in protractor.conf.js file but in the path: node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.25.exe

the chromedriver was 2.25 version so i edited the entry

webbrowserDriver = prefix + 'node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.25.exe';

and it worked!



标签: protractor