Headless Selenium on Ubuntu 14.04 with PhantomJS 2.0

Headless Selenium on Ubuntu 14.04 with PhantomJS 2.0

N.B. This is STILL incomplete.

More work later 🙂

We’re following the excellent Headless Selenium Testing With Python and PhantomJS

Install Selenium

Let’s use pip to install Selenium

$ pip install selenium

Install PhantomJS

To make PhantomJS installation easy we will use the GitHub Repository, PhantomJS 2.0 built on Ubuntu 14.04 x64.

  1. Let’s login as root, cd to the root home.
    $ # However you login as root - I use WinSCP & Putty.
    $ cd ~
  2. According to the notes on the GitHub, to avoid the noticed dependency error, first let’s install “libicu52”.
    $ sudo apt-get install libicu52
  3. Now let’s just follow the original instructions on the GitHub Repository.
    $ # Since the file the GitHub Repository is 
    $ #    **actually** the phantomjs **executable**, 
    $ # And we want system wide access,
    $ cd /usr/bin
    # Now do our GitHub Repository wget into /usr/bin
    $ $ wget https://github.com/Pyppe/phantomjs2.0-ubuntu14.04x64/raw/master/bin/phantomjs
    # Now change the permissions
    $ chmod 0755 phantomjs
    $ # -rwxr-xr-x 1 root root 56596085 Aug 26 09:22 phantomjs

    That does it.

Love and peace,


#automation, #test-suite

Make the Eclipse JUnit Test Suite wizard work for JUnit-4

I recently got back into Java being inspired by the growth of the Android platform and Java’s close link to it. I needed a refresher tutorial on Java and Eclipse and found “Eclipse and Java for Total Beginners” which after getting over my pride and reviewing the first couple of lessons is just what I needed. This very well thought out and produced tutorial also gives an excellent introduction to “Test Driven Development”. Another benefit.

The Problem.
The tutorial is based based on JUnit-3. I installed the more up-to-date JUnit-4 and the Eclipse “JUnit Test Suite” wizard BLEW UP! :..)… I googled “eclipse JUnit 4 Test Suite wizard problem” and concluded that it seems to be well known, so I thought I’d publish my work-around here.

The Work-Around. 
The specific variable names in the work-around are based on the tutorial code. You can see what the tutorial recommended by going to Lesson- 8 at about 10min:50sec. Here is the work-around:

-in Package Explorer View TotalBeginner/test rclick org.totalbeginner.tutorial
        wizard dialog comes up
            -next, press Finish to select default of (BookTest, PersonTest)
                creates a new class AllTests
-*** wizard will say ***:  
    Warning: No test classes selected
    *** because i use JUnit-4 Wizard needs JUnit-3 ***
    -click Finish anyway
-Fix wizard generated code
    1. delete everything from the wizard code 
        EXCEPT the package definition in this case:
            package org.totalbeginner.tutorial;
    2. put in something like the following code 
        2.1 here's the code:
            @Suite.SuiteClasses(value={BookTest.class, PersonTest.class})
            public class AllTests {}
        2.2 Change/Add to the example "BookTest.class" & "PersonTest.class" items,
            appropriate items for your situation. 
        2.3 use eclipse quickfix to create appropriate import statements
            -click in error code marked with red squiggly underline
            -ctl-1 for quick fix
            -select suggestion that generates the appropriate import
            -continue until no more errors 
            -for this example 2 imports were generated:
                import org.junit.runner.RunWith;
                import org.junit.runners.Suite;

#eclipse, #java, #junit-4, #test-suite