0

When I want to have automated browser function with selenium-webdriver, I write at first with chrome driver and then make it run with phantomjs.

But sometimes the two browsers behave differently and the function fails to run with phantomjs while selenium-webdriver works fine.

Currently, to find out what is wrong I am struggling in command line. I wonder if there is a way to run phantomjs with "head" so that I can see the problem at a glance. Or maybe is there way to make chrome behave exactly like phantomjs?

I'm aware of some web site are restricted to get information by headless server, I'd give up in that case.

Edit:

  module.exports = {
  init: function () {
    browser.ignoreSynchronization = true;
    browser.driver.manage().window().setPosition(0, 0);
    browser.driver.manage().window().setSize(2000, 1200);
    browser.driver.get('https://www.google.com');
    browser.waitForAngular();
    browser.driver.sleep(2000);
  },

login: function (user, company) {
    element(by.css('[aria-label="Search"]')).click();
    element(by.css('[aria-label="Search"]')).sendKeys('tkc@bn.co');
    browser.driver.sleep(1000);
    element(by.css('.sbico')).click();
    expect(browser.driver.getCurrentUrl()).toContain('https://www.google.com/#q=tkc%40bn.co');}

This code will just visit google, type in the field and click search. Works fine with chrome. Does not pass on phantomjs.

tosh
  • 337
  • 1
  • 3
  • 13
  • 1
    http://stackoverflow.com/a/28364664 – Artjom B. Mar 26 '15 at 16:35
  • Different browser engines have different behaviours. – SiKing Mar 26 '15 at 16:44
  • But I heard phantomjs is suppose to mimic chrome. – tosh Mar 26 '15 at 16:57
  • Also, I am unable to download chrome 13 since it was removed? – tosh Mar 26 '15 at 17:05
  • @tosh No, PhantomJS isn't supposed to mimic Chrome. It is only coincidentally that there was a time that both used the same engine. The engine of PhantomJS 1.x is 4 years old. Chrome has simply more features and fewer (different) bugs. Try PhantomJS 2, because its engine is only more than a year old. – Artjom B. Mar 26 '15 at 19:32
  • @ArtjomB. Alright, I'll try it but I need steps on how to. Do I need to update the version of dependicies in bower.json/package.json/karma.conf.js/ads-e2e.conf.js ? Do I just need to install it on my local machine? Ultimately I am going to use jenkins to run my tests which uses phantomjs. – tosh Mar 26 '15 at 20:55
  • Looks like you are in dire need of some logging in there somewhere. With UI-based browsers, not having logging doesn't matter as much, because you can watch them run and see when they fail (logging still useful, just trying to highlight a point), but with PhantomJS, logging is the only way you're going to find out what went wrong. – aholt Mar 27 '15 at 16:29
  • How do I log with phantomjs? @aholt – tosh Mar 27 '15 at 18:03

0 Answers0