Cloud9 Watir/Selenium Testing - selenium

I have set up Cloud9 and Codeship for a simple Continuous Integration and Delivery system. It works well for developing my website/app. Has anyone been able to develop and run browser based Cucumber tests from within the Cloud9 IDE? If so, what kind of set-up did it require?
PS. I have been trying to get the Watir/Selenium chromedriver installed and working with the 'headless' gem.

First an explanation. I found it very easy to set up github, c9.io, and codeship for CI and CD using Cucumber for acceptance testing on Codeship. Unfortunately, developing the Cucumber tests was difficult, because I had to commit, push, and examin the failing Integration tests on codeship. I wanted to be able to quickly run and debug Cucumber scenarios in the IDE. But, there is no browser for watir/selenium to open. Thus the question.
After a day of searching and hint from c9.io on twitter, I have consensed the solution down to two steps ...
Install firefox and xvfb: sudo apt-get install firefox xvfb
Run cucumber in an xvfb context: xvfb-run cucumber

Related

How does the elixir community recommend setting up integration tests with chromedriver?

I am using Hound (https://github.com/HashNuke/hound) for integration testing a Phoenix application. I have chrome and chrome headless working. To get it working I have another terminal window running chromedriver (installed via brew). This feels odd to me. Is there a library or test setup that would feel more "integrated" into the application? What's the Elixir way of doing this?
In the Ruby world there's the webdrivers gem (https://github.com/titusfortner/webdrivers). As far as I know it downloads a specified driver (lets say chromedriver) to $HOME. Then with every test run, the test uses the driver downloaded to that destination to execute the tests.
Before the webdrivers gem there was chromedriver-helper gem. Before that it was phantomjs. These implementations made it so running integration tests required 1: downloading the driver 2: running the test
In Elixir (with Hound) I have my tests working by first running chromedriver --verbose in a terminal split, and in the other screen I run mix test. This works fine but feels disjointed. This adds extra steps, 1: download the driver 2: start the driver 3: run the test 4: stop driver
I could write a script manually to run chromedriver in the background, and stop it after the tests are run.
I am new to the Elixir community and so I've researched a lot. It's still not clear to me if there is a "traveled path" I should go down vs just hooking everything up manually.
Have I missed a recommended abstraction? Is this intentional? Is this "just not created, yet"?
Thank you
Have you checked out wallaby? See https://github.com/keathley/wallaby

Can Xvfb be enabled in Jenkins declarative pipeline in order to execute Selenium headless tests

Trying to enable Xvfb in Jenkins declarative pipeline to be able to run Selenium headless tests from the pipeline definition.
Have been able to run Selenium tests in a standard Jenkins (Linux) job. That's fine, i.e. Xvfb can be enabled under build (after plugin install) in the Jenkins job and then can Python virtual env be setup and Selenium tests executed from shell.
But I want to have a pipeline scope/setup. But in pipeline type jobs the Xvfb doesn't show up. And I haven't been able to find an answer if and how it can be enabled from the declarative pipeline code itself. Is it possible?
Is there any workaround?
Yes you can, every job which is pipeline have a link on left side of job page "Pipeline Syntax" when you go there it will help you a lot for some non obvious cases. So, for your case:

Testing with Web Driver and Selenium through Codeception

I know I'll get crap for this but it's worth it if someone can help.
I can't find a guide, tutorial, or instructions anywhere for installing web driver on a windows machine. I've got a site running on a homestead vagrant box and need a way of running acceptance tests locally. I had tests setup using PhpBrowser but those don't simulate JavaScript. If anyone knows of a guide to do this or a better way to run acceptance tests it would help immensely. I've got Ajax calls so PhpBrowser and resources like it won't work.
Thanks!
Just download the selenium webserver the jar file and run it in a command shell with java -jar selenium-server-standalone-2.43.1.jar. The selenium server will now listen on the default port 4444. If you run your test it should work as expected. Keep in mind that selenium webserver opens firefox and uses it for testing. It's pretty useful for watching the test cases.
If you want a headless test (no visible browser) you need to download phantomjs. Unpack it and run the phantomjs.exe with --webdriver=4444 as an argument (so phantomjs.exe --webdriver=4444).
Download and Run the selenium-server-standalone-2.43.1.jar as stated in the comment. I had to add firefox_binary: C:\Program Files (x86)\Mozilla Firefox\firefox.exe under capabilities: in my acceptance.suite.yml file. I also added it to the path variable but I'm not sure if that made a difference. Had to add the firefox_binary to make it work.

Is there a way to run Jasmine 2 tests with Selenium Webdriver?

I have a large suite of Jasmine unit tests that were developed to run on a Selenium Grid using the jasmine:ci rake task provided by the Jasmine 1.3 Ruby gem. There was decent integration between Jasmine 1.3 and Selenium Webdriver and running tests on a remote node was as simple as passing some environment variables:
$ rake jasmine:ci SELENIUM_SERVER="http://hub.localdomain:4444/wd/hub" JASMINE_HOST="http://currenthost" JASMINE_BROWSER="chrome"
In Jasmine 2, this capability is gone, replaced by an integration with Phantomjs. Unfortunately, I can't find any discussion of migration options for people who still need Webdriver support.
Is there a way to run Jasmine 2 tests using Selenium Webdriver? Does anyone know of any existing projects or documentation focused on this integration? My query to the Jasmine dev list has gone unanswered.
On the jasmine team, it seemed to us that most people wanted to run their tests headless, so with 2.0 we made that the default. Running the tests in selenium also made the jasmine gem have a number of dependencies that potentially made it harder to install.
But we also see the value in running jasmine tests in multiple (real) browsers as well. To this end, we extracted the selenium code, including saucelabs integration, to it's own gem. Jasmine core actually uses this gem to runs it's own tests across multiple browsers.

Selenium testing machine

--- 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?
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
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
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'.