protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Browser.get issue on phantomjs

Open henrytao-me opened this issue 12 years ago • 6 comments

Hi all, I have successful config protractor and phantomjs webdriver. It works good, except when ever I call browser.get('some_url'), it fires issue like:

UnknownError: cannot forward the request The target server failed to respond
      at new bot.Error (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109:18)
      at Object.bot.response.checkResponse (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
      at /Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:276:20
      at /Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
      at webdriver.promise.ControlFlow.runInNewFrame_ (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1598:20)
      at notify (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:428:12)
      at notifyAll (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:397:7)
      at resolve (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:375:7)
      at fulfill (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:493:5)
      at /Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1465:10
  ==== async task ====
  WebDriver.executeScript()
      at webdriver.WebDriver.schedule (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:267:15)
      at webdriver.WebDriver.executeScript (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:401:15)
      at Protractor.get (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/lib/protractor.js:888:22)
      at /Volumes/iMac/workspace/github/coral.io/frontend/test/protractor/spec/workspace.js:6:21
      at webdriver.promise.ControlFlow.runInNewFrame_ (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1598:20)
      at webdriver.promise.ControlFlow.runEventLoop_ (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1463:8)
      at wrapper [as _onTimeout] (timers.js:252:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
  ==== async task ====
      at Context.<anonymous> (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/protractor/node_modules/selenium-webdriver/testing/index.js:123:12)
      at Test.Runnable.run (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/mocha/lib/runnable.js:204:15)
      at Runner.runTest (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/mocha/lib/runner.js:374:10)
      at /Volumes/iMac/workspace/github/coral.io/frontend/node_modules/mocha/lib/runner.js:452:12
      at next (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/mocha/lib/runner.js:299:14)
      at /Volumes/iMac/workspace/github/coral.io/frontend/node_modules/mocha/lib/runner.js:309:7
      at next (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/mocha/lib/runner.js:247:23)
      at Object._onImmediate (/Volumes/iMac/workspace/github/coral.io/frontend/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:330:15)

I don't know why. Then, I found that if I call browser.navigate().to(browser.baseUrl + 'some_url'), it works on both Chrome and PhantomJS.

I don't know what's happen with browser.get() function. So, in order to make it work. I modified the get function like this:

describe('init', function(){
    it('should init', function(){
        browser.get = function(url){
            var url = browser.baseUrl + url;
            browser.navigate().to(url);
        };
    });
});

I would like to have your idea. How to call browser.get() without modifying it?

henrytao-me avatar Apr 08 '14 06:04 henrytao-me

Try:

browser.ignoreSynchronization = true;
browser.get(myUrl);
browser.ignoreSynchronization = false;

Not sure what's going on with Phantom to cause this issue, it looks like a new one.

juliemr avatar Apr 11 '14 19:04 juliemr

same issue, running on a mac env with phantom via a selenium hub. the ignoreSynchronization fixes it for me

levexis avatar Jun 27 '14 16:06 levexis

Does anyone using phantom know if this is still an issue?

juliemr avatar Mar 17 '15 23:03 juliemr

I have been testing with protractor and all my test spec are passed successfully when I used the firefox browser. But when I change to phantom all my running test spec that have been passed on firefox browser has failed and returning error code 1. Is there any who could help me please?

dotjose-zz avatar Oct 08 '15 10:10 dotjose-zz

I think that this issue is obsolete, I'm closing. Please open a new issue if you have a reproducible test case. Thanks!

juliemr avatar Jul 13 '16 20:07 juliemr

I don't have a reproducible scenario to share, so I won't open a new issue. I'll just share the info with you, so you know the problem is still there.

I have the same problem with browser.get not working in phantomjs. Everything works as expected in chrome and firefox, but phantomjs seems to ignore browser.get() calls. The fix with browser.ignoreSynchronization did not help.

I am using mac, phantomjs-prebuilt v2.1.13 and the recommended configuration (https://github.com/angular/protractor/blob/master/docs/browser-setup.md#setting-up-phantomjs):

capabilities: {
  'browserName': 'phantomjs',
  'phantomjs.binary.path': require('phantomjs-prebuilt').path,
  'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']
}

korya avatar Nov 22 '16 17:11 korya