Monday, July 18, 2016

AUTOMATION 17 - GUI 5, Setting up a Selenium project

Technical level: ****

Last time we installed everything we needed for Selenium WebDriver.  Before we can try out some instructions, we need to set up our Java project area, including importing the Selenium JAR library.


Creating your project

First you need to setup your project area ...

From the menu select File -> New -> Project



Select Java Project, then Next

 
Set a project name as project Aardvark & select Finish


 Your project is now all set up.

 


Create a (main) Java class

Now you need to define the main Java class for your project...

Now, right click it an select New -> Class



From the Java Class select “public static void main (String[] args)" checkbox, type a Name of “PageChecker” then Finish.  This sets up a main function in the Java class, which is central to being able to run your script when you’re ready.


Once finished it should look like,



Link in the Selenium JAR libraries

Now need to add in the Selenium JARs we downloaded last time...

Right click on Project Aardvark and then Build Path -> Configure Build Path



Select the Libraries tab and Add External JARs


 Add in ALL the .jar files you downloaded from Selenium and extracted into your Documents folder – including those in the libs files …



Then select OK.

You should now save your project area – you’re ready for your first automated check, which we'll cover next time.

New Step - Bring in the browser driver Added 22/08/16

Since this post was originally printed, there have been some changes which have impacted how WebDriver works.  Read about it here.

It used to be that you could operate Firefox out-of-the-box.  Now you need to bring in Gecko driver executable and bring it into the folder you have your PageChecker project in.

You can download the drivers from here - but as the page says, be aware that they are third party drivers!



No comments:

Post a Comment