2

Hello I'm a novice when it comes to this so forgive my ignorance.

I'm trying to port over my Selenium test to a linux based server, however the linux server has no GUI and cannot run an exe (Chromedriver). My selenium test is in a JAR the server is a red hat linux server.

I thought I could just port my test over and use the linux based chromedriver but I doubt that would work since it needs a display and chrome to actually do the work.

So how can I run my test on cron which doesn't allow the GUI of chrome? I've read a bit into running chrome headless with XVFB but I'm not too sure if thats the right direction. If someone could point me in the right direction with links or advice on how to make it happen that would be great.

1

Cron is just the default linux scheduler. If you want to schedule tests on a linux machine you need to be able to run them first without the scheduler. Once you got that working scheduling is the easiest part.

Using XVFB still seems to way togo if you use Java&Linux, but all the tutorials are 3 years old. This stackoverflow.com answer seems pretty complete: https://stackoverflow.com/a/15514348/1088584

Personally I would look at a headless browser like PhantomJS, but for Java you need a special implementation like jBrowserDriver. Or GhostDriver, but that is not maintained anymore.

Instead of cron I would have a look at a CI-server like Jenkins. Those are so much better in scheduling and reporting on test-runs.

Maybe instead of setting up your own VM's have a look at Selenium WebDriver cloud services like BrowserStack, TestingBot or SauceLabs. This saves you the setup and maintenance.

  • Wanted to thank you Niel, the phantomJS actually solved my problem completely. My test still runs but there is no GUI and it is headless. Thanks a bunch :) – Christian Feb 3 '17 at 21:18
  • The problem with PhantomJS is that it is not a real browser. Chrome is using now a different fork of WebKit and since latest release of PhantomJS on January 23, 2016 many new versions of Chrome and Safari have been released. We've been there an found we're missing many bugs that we would have found if using Chrome or Safari. – dzieciou Feb 6 '17 at 6:59
  • Good point, wasnt aware it wasnt uptodate. There are other headless browsers. Looks like a chromium which should be comparable with the latest chrome and Nightmare which uses electron as its base, which is also based on chromium. For more options look at github.com/dhamaniasad/HeadlessBrowsers – Niels van Reijmersdal Feb 6 '17 at 18:51
  • Still PhantomJS could be used as fast feedback on developers machines and during the CI-phase you use a real browser. We use Teamcity Windows agents as they are able to run nearly all browser versions. – Niels van Reijmersdal Feb 6 '17 at 18:52
1

Niels' answer (headless browser) is one option. Another option is to have a VM with real browser, like Chrome, and point Selenium to use that.

In fact, even if you use headless browser, you should run your tests against real browser(s). Browsers should be compatible (in ideal world) but we are not there yet.

In theory, there is no difference between the theory and the reality. In reality, there is. As QA, you should develop a habit to NOT blindly trust the components of your system behaving as they are supposed to: Sometimes they do not. Trust, but verify.

0

Yes, Jenkins solution is better than cron. As for the headless browser, you may use HTML Unit driver. Another solution that helps to use webdriver in non Gui mode is to use XVirtual frame buffer for Linux. Using it you may utilize both Chrome and Firefox drivers. The whole solution, that includes Jenkins, Selenium Firefox driver and Blazemeter with using XVirtual frame buffer on Linux is described here: Headless Execution of Selenium Tests in Jenkins - . In this solution Jenkins is used to orchestrate test launches.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.