5

--- TL;DR

At this point I suggest everyone to tied their Continuous Integration server/service to https://ghostinspector.com/

OLD QUESTION

after three days googling and testing I gave up, and I need help.

My objective is allow my co-workers to record one or more tests with Selenium IDE. Export them, upload them into a server, and get this server running these tests using the webdriver with htmlunit. As we build or fix the app, we will upload the tests to make out test library.

Record a test with Selenium IDE is okay. But getting it running is the problem. The machine we intend to let the tests is an linux amazon server. No front-end stuff, no kde, gtk, so no firefox, chrome, etc... This is why I've specified the htmlunit driver.

So far I wasn't able to get this task running even into my machine - Ubuntu 12.04 x86_64.

I downloaded the selenium-server tarball, and tried running:

java -jar selenium-server.jar -htmlSuite "*webdriver" "our.site.org" "/path/to/testsuite1.html" "/path/to/report1.html"

No success. Even changing the "*webdriver" (using other pops-up a browser screen).

I've tried running the server and the standalone server and connecting via browser.

I've tried PHP bindings by facebook.

I've tried PHPUnit and Testing Selenium classes - along with their respectives exported scripts from Selenium Formatters.

I really do not know where I'm slipping. Can anyone give me a safe direction, tutorial, etc, to follow with?

--- EDIT

Okay, my question may be resumed to:

What si the command line that would allow me to run selenese scripts with selenium-server, using the HtmlUnit driver?

Davis Peixoto
  • 5,695
  • 2
  • 23
  • 35
  • 1
    Why not use Selenium WebDriver instead? – aimbire Feb 27 '13 at 14:18
  • Using the plain webdriver needs you to have the browsers installed - option I discarded, since it is just a really headless server - or, using HtmlUnit which requires selenium-server to be installed. – Davis Peixoto Feb 27 '13 at 16:36
  • I do most of my automated scripts using only HTML driver, no need for a browser tbh. And you're going to need the server either way. – aimbire Feb 28 '13 at 12:17
  • @aimbire would you like to answer with the how I can use the htmlunit driver? I still couldn't find out how to do it. – Davis Peixoto Mar 15 '13 at 20:43
  • No problem, just hope it helps. I found that HTML Driver can't understand some JavaScript in the pages i test, so i keep them for the simple tests. – aimbire Mar 20 '13 at 15:26
  • Have you tried the WebDriver+Xvfb approach? My Jenkins runs acceptance tests in JRuby with gems watir-webdriver (which is based on selenium-webdriver) and headless (which leverages an Xvfb session): I'm quite sure you could do something similar. – Vincent Mar 21 '13 at 11:30
  • @Vincent I'm using that approach currently. Xvfb + webdriver + firefox to run selenese tests. But I'm trying to figure out how to run the tests without firefox and xvfb; using htmlunit instead. – Davis Peixoto Mar 21 '13 at 14:06

3 Answers3

4

Are you using Continuous Integration? If so, you should consider getting a plugin to have your CI software run the Selenium tests. Works like a charm for me with Jenkins.

Considering your particular setup, you could both have the amazon linux server run the tests with HTMLUnitDriver, and declare other machines (with a GUI and proper browser) as "nodes" to run your test on other browsers.

Link to a tutorial

Silver Quettier
  • 2,045
  • 2
  • 26
  • 53
  • Thx for your reply. We are studying how and when implement the CI here in the company, but it's not gonna happen for a while. The link you sent is cool, really cool, but my question right now is: how can I run that command line using htmlunit driver instead of firefox driver? There is no option *htmlunit option. – Davis Peixoto Feb 25 '13 at 19:44
2

Have you read this blog post by David Burns (Automated Tester):

http://www.theautomatedtester.co.uk/tutorials/selenium/selenium_rc_setup.htm

He describes the way to run selenese tests using HTMLSuite.

We are going to use the HTMLSuite commands of the Selenium Remote Control. This allows you run your Selenese Test Suites as is. The command should look like java -jar selenium-servre.jar -htmlsuite . Browser could be : -*firefox -*chrome -*iexplore -*iehta -*safari -*custom /path/to/browser

The path to the test suite and the results file should be a full path.

Here is an example command; java -jar selenium-server.jar -htmlsuite *iexplore http://www.theautomatedtester.co.uk c:\testsuite\testsuite.html c:\testsuite\results.html

I would point out that htmlunit does not seem to be a supported option so I would expect to use -*custom and provide a path to htmlunit.

This is legacy functionality so there is a chance it doesn't work as expected any more. HTMLSuite expects the tests to be in Selenese (HTML table) format, you mention trying with the PHP binding, I would not expect this to work. If you do want to use some PHP bindings I would suggest using Adam Saunter's fork of the facebook bindings, they are the most up to date and best supported.

https://github.com/Element-34/saunter.php

Ardesco
  • 7,281
  • 26
  • 49
  • I already have the selenese testing machine installed into a EC2 Amazon AMI-based instance, running tests with Firefox 19. The question is really about how to run those with HtmlUnit. – Davis Peixoto Mar 19 '13 at 16:08
  • To quote the above: "I would point out that htmlunit does not seem to be a supported option so I would expect to use -*custom and provide a path to htmlunit." – Ardesco Mar 19 '13 at 17:07
0

With Selenium WebDriver you can point to start a HtmlUnit in a already started node

In Java you'll do something like this:

IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.HtmlUnit());

To start the node just make sure to set browserName to 'htmlunit'.

aimbire
  • 3,697
  • 1
  • 15
  • 28
  • @aimbirre, yeah, I know this approach too. But I'm avoiding to code anything. I need to keep the tests as much as selenese as possible in my current task. This is a limitation I can't override right now here. – Davis Peixoto Mar 21 '13 at 14:08