I've got a Selenium project + Java + Maven that runs normally on Chrome driver. However, I've been trying to make it work with PhantomJS, but I've encountered a problem. The same code that works on Chrome driver doesn't work on PhantomJS. I've debugged a lot and realized that the problem is that the page source that gets loaded is different with PhantomJS. The IDs that I try to locate are not present.
When using System.out.println(driver.getPageSource());
, the output for:
Chrome driver: length: 19,233
PhantomJS driver: length: 14,965
I've tried to set size as someone suggested in another post (driver.manage().window().setSize(new Dimension(2000, 1500));
), but that doesn't help either.
I've tried waiting longer for the page to load, didn't help.
I've also checked the link in driver.get() and it's a full URL with http:// at the beginning.
As we're going to need all the tests to run both on Chrome and on PhantomJS, I'd rather if we didn't need to check the PageSource everytime we write a test and look for something that's present on both.
I'd appreciate any help. :)