I'm trying to use PhantomJS 2.0/GhostDriver instead the ChromeDriver, since I have read I could speed up my UI tests. This is the test code I'm running, as part of a Junit test:
@Override
public void runTestCase() throws Exception {
long startTime = System.currentTimeMillis();
// log in as admin
Login.loginAs("admin", "password");
System.out.println(System.currentTimeMillis() - startTime);
}
The loginAs
function fills in the text fields for the username and password, then click on the submit button and finally moves in the home section of the new returned page.
Now, I'm running once a time this simple test using both Phantomjs and ChromeDriver as driver for Selenium in Java (v2.45). They are initialized as follow:
ChromeDriver
System.setProperty("webdriver.chrome.logfile", workingDirectory + "\\chromedriver.log");
service = new ChromeDriverService.Builder().usingDriverExecutable(new File(workingDirectory + "\\chromedriver.exe")).build();
capabilities = DesiredCapabilities.chrome();
options = new ChromeOptions();
options.addArguments("--allow-file-access-from-files");
options.addArguments("--verbose");
capabilities.setVersion("");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(service, capabilities);
PhantomJS
System.setProperty("phantomjs.binary.path", workingDirectory + "\\phantomjs.exe");
cliArgsCap = new ArrayList<String>();
capabilities = DesiredCapabilities.phantomjs();
cliArgsCap.add("--web-security=false");
cliArgsCap.add("--ssl-protocol=any");
cliArgsCap.add("--ignore-ssl-errors=true");
cliArgsCap.add("--webdriver-loglevel=INFO");
cliArgsCap.add("--load-images=false");
capabilities.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true);
capabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
driver = new PhantomJSDriver(capabilities);
I'm running my test on a 64bit Windows 7 machine. So, having a look the time took by the test, I always note that ChromeDriver is faster than PhantomJS. Always. For instance, if the test with ChromeDriver takes about 3-4 seconds, the same with PhantomJS takes about 5-6 seconds.
Has anyone experienced with this issue? Or could anyone give me any reason for that? Am I setting something wrong?
Furthermore, if you need more details, let me know.
I have found that this setting uses a lot of memory that seems to keep growing:
cliArgsCap.add("--load-images=false");
But when I use this setting the memory usage is stable:
cliArgsCap.add("--load-images=true");