
In our previous blog post Docker setup and installation on Ubuntu , we have done installation of docker. Execute the test with real browsers in headless mode. Now, its time to say goodbye to your third party headless browsers. This can tremendously reduce execution time when you will execute your large test suites.
Execution time in headless mode – 9.321 seconds. Execution time in non-headless mode – 12.193 seconds. Below is time analysis for a simple test which navigate to google and search for some text : I have also done some time comparison with chrome browser headless and non headless mode. RemoteWebDriver driver = new RemoteWebDriver( FirefoxOptions ffoptions = new FirefoxOptions() WebDriver driver = new FirefoxDriver(options) Īlso, its very easy to do your selenium Grid configuration for your remote test execution. Similarly, we can use FirefoxOptions to enable headless mode for Firefox browser tProperty("","Path to gecko driver exe") įirefoxOptions options = new FirefoxOptions() WebDriver driver = new ChromeDriver(options) ĭriver.findElement(By.name("q")).sendKeys("hello") tHeadless(true) //this line is actually enables the headless mode tProperty("","Path to chrome driver exe") ĬhromeOptions options = new ChromeOptions() Lets go through a sample code for google test for Firefox and Chrome respectively. Please make sure to utilize this feature, you are using selenium version 3.6.0 and above. Now lets look at how to make our browser run in headless mode during our test execution. Now with selenium version 3.6.0 on-wards you can run your real browsers(chrome and Firefox) test in headless mode. This time it has just blown the need for headless browsers like phantomjs etc. Selenium always surprises us with some cool new features. That will obviously solve our above problem. But what if we run our real intended browsers in headless mode during our test execution.
These problems happen as Xpath engine and java-script engine implementation varies from browser to browser and specifically for headless browsers.
Additional line of code to handle cookies and other issues.Īnd there are many more problems apart from above mentioned.
Same locators(xpaths, CSS selectors) do not work when test executed on headless browsers.GhostDriver, PhantomJs driver), but we have always seen below issues with these browsers. Best way of it is obviously running your test with headless browsers (e.g. Being CD/CI a crucial need, its very important to run our test quickly. Time has always been a factor to measure the efficiency and effectiveness of our automated test scripts.