Tuesday, August 16, 2016

AUTOMATION 23 - GUI 10, Switching to Chrome

Technical difficulty: ****

Last week I reported on the recent changes to Selenium WebDriver.  Specifically they impacted using Firefox out-of-the-box, meaning you needed to download an position a new driver to make it work.

I was hoping it'd be all sorted by today - but alas no.  Although generally good, I'm getting issues on some basics - to confirm it's the new Gecko driver, I've tried running on Chrome, and found the issues vanish.

Update Selenium WebDriver in your project area

Switching to Chrome is relatively easy - but first we need to update our version of WebDriver used in our project.  Start with downloading the latest version of Selenium Webdriver here, and extracting it to somewhere on your system (remember where).

Under Eclipse, I've gone into my project gone Build Path -> Configure Build Path

There I've removed the previous .jar files for the last Selenium WebDriver build I've done, and then used Add External Jars to add back in all the new ones.

Put the browser driver into place

The Google Chrome driver (and indeed the Gecko driver) are a form of middleware which acts between the software of the Selenium WebDriver and the browser itself.  You'll sometimes hear the word "marionette" used to describe it, because this software essentially "pulls the strings" on your target browser.

Now, you need to download the Google Chrome Driver from here,

Now a little more tricky - to make this work it needs to be copied into your project workspace, for me it goes ...

You might notice I've also placed a version of the Firefox Gecko driver there as well.

Change your code

This is really simple - first off in your header you need to include the following,

    import org.openqa.selenium.chrome.ChromeDriver;

This includes the objects and methods needed for the ChromeDriver.  You then change your declaration of,

    WebDriver driver = new FirefoxDriver();

To ...

    WebDriver driver = new ChromeDriver();

That's pretty much it.  Although in reality there can be oddities thrown out by a change of browser - I found mine regarding the selection of frame which contains "Enter your comment".  I modified my code to use an algorithm which looked through all the frames on the page, selecting the one which says "Enter your comment" ...

I've already committed these changes to my Github page - find me there.  Really it's the second project which has had the most revision to include that frame search, which is here.


  1. This comment has been removed by a blog administrator.

  2. I am glad to see this post on your website. It is beneficial for us and can be very useful in our daily life, and we always use your website information and experiences. Anyway, thank you so much.
    digital marketing services in india

  3. Nutra Trials defines personal characteristics of different health products including skincare, weight loss, muscle and male enhancement. The study presented here is briefly described for reader convenience and to deliver them assurance with health standards. The best possible answers are given here regarding the selection of an ideal supplement or cream or serum that possibly remains to be safe for health and do not cause any side effects.

  4. It is a great job, I like your posts and wish you all the best. and I hope you continue this job well.
    NutraT line

  5. Enduro stack Testosterone Booster is much safer than taking steroids or random supplements from the drugstore. Because, those supplements aren’t quality controlled or checked for safety, unlike this one. And, the majority of these products rely on artificial ingredients, fillers, and binders. Overtime, artificial ingredients can harm your body by building up toxins in it. Now, you can avoid that situation altogether with Enduro stack. Because, this supplement is completely natural, and it boosts testosterone the safe way. So, you can finally get results without worrying about hurting your body. Click below to order your own Enduro stack free trial!
    Enduro Stack

  6. Hello, I am thomus jons thank you for this informative post. That is a great job. Wish you more success.Thank you so much and for you all the best. Takes Down