<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hrvoje Ruhek on Medium]]></title>
        <description><![CDATA[Stories by Hrvoje Ruhek on Medium]]></description>
        <link>https://medium.com/@hrvoje.ruhek?source=rss-1098358f43fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9-lvA04B-m7o5bUi.jpg</url>
            <title>Stories by Hrvoje Ruhek on Medium</title>
            <link>https://medium.com/@hrvoje.ruhek?source=rss-1098358f43fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:11:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hrvoje.ruhek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating management of Selenium webdriver binaries with Java]]></title>
            <link>https://medium.com/agency04/automating-management-of-selenium-webdriver-binaries-with-java-3a70c4a9b2d5?source=rss-1098358f43fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a70c4a9b2d5</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[automated-testing]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Hrvoje Ruhek]]></dc:creator>
            <pubDate>Mon, 12 Aug 2019 13:30:46 GMT</pubDate>
            <atom:updated>2020-02-24T10:51:03.128Z</atom:updated>
            <content:encoded><![CDATA[<p>Manual setup of testing environment for <strong>Selenium</strong> can be tiresome. Installed browser version and Selenium webdriver binary version need to be in sync. When you need to do it on multiple machines, each with different OS, it takes a lot of time and effort.</p><p>There is a nice javascript tool <a href="https://www.npmjs.com/package/webdriver-manager">webdriver-manager</a> that is useful if you can install node.js on your testing environment, but it’s useless if you only have Java available.</p><p>At first I wrote custom Gradle build scripts. It took a lot of effort to maintain them and they were useless on projects that used Maven. Then I found one awesome Java project that solves the problem. It’s <a href="https://github.com/bonigarcia/webdrivermanager">Boni Garcia’s Webdriver manager</a>.</p><p>The project is actively maintained and has excellent documentation. WebdriverManager can be used as a standalone server that fetches Selenium webdriver binaries, or you can include it as a dependency in your project and use it directly in your test code.</p><figure><a href="http://bit.ly/MediumAGENCY04"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tquvcAixKbvB7IvqqXTl8Q.png" /></a></figure><h3>Selenium test example</h3><p>We will create a simple <strong>Junit</strong> test with Selenium. We will use <strong>Gradle</strong> as our build tool.</p><h4>Prerequisites</h4><ul><li>Java JDK 1.8.X</li><li>Gradle 5.X</li><li>Firefox browser</li></ul><h4>Test overview</h4><ul><li>fetch the right Firefox driver binary if needed</li><li>create instance of Firefox webdriver</li><li>visit Google search page with Firefox browser and do a search for AG04</li><li>Verify that first result is “Agency 04”</li><li>close browser after test</li></ul><h3>Project setup</h3><p>We need to create a new directory for our project. We will create a simple gradle project in it that uses Groovy as build script DSL in it by invoking gradle init command.</p><pre>mkdir webdriver-manager<br>cd webdriver-manager<br>gradle init</pre><p>Than we will add following code to <strong>gradle.build</strong> script</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fb7033472daf0bc9cfc01e6657abc32/href">https://medium.com/media/5fb7033472daf0bc9cfc01e6657abc32/href</a></iframe><h3>First test implementation</h3><p>We’ll create a directory for <strong>com.ag04</strong> test package.</p><pre>mkdir -p src/test/java/com/ag04</pre><p>There we will create out first test class.</p><pre>touch src/test/java/com/ag04/GoogleTestExample.java</pre><p>We’ll add the following Java code to <strong>GoogleTestExample</strong> class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dcd97406312b886cac9526ea2022b88e/href">https://medium.com/media/dcd97406312b886cac9526ea2022b88e/href</a></iframe><p>We are using standard Junit annotations. WebdriverManager does its magic in a method annotated with <strong>@BeforeClass</strong>.</p><p>Annotated with <strong>@Before</strong> and <strong>@After</strong> are setup and teardown of webdriver instance.</p><p>We start test by typing:</p><pre>./gradlew clean test</pre><p>We can see what the WebdriverManager does in the Gradle log output if we add the <strong>info</strong> parameter when we invoke the gradle <strong>test</strong> task.</p><pre>./gradlew clean test --info</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0E3RTTPcoF-4OLKgKFBmQ.png" /><figcaption>WebdriverManager does its magic!</figcaption></figure><h3>Page objects pattern</h3><p>A common pattern used in browser automation is <a href="https://github.com/SeleniumHQ/selenium/wiki/PageObjects">Page objects pattern</a>.</p><p>We will create a new directory for <strong>com.ag04.pages</strong> package.</p><pre>mkdir src/test/java/com/ag04/pages</pre><p>Next, we need two new classes for the search page and the results page.</p><pre>touch src/test/java/com/ag04/pages/HomePage.java</pre><pre>touch src/test/java/com/ag04/pages/ResultsPage.java</pre><p>We will add the following code to these classes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f122d1cb2c90397c7f8b1cc276e256cf/href">https://medium.com/media/f122d1cb2c90397c7f8b1cc276e256cf/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cfe6e43ba69d58e9177565b9f738813/href">https://medium.com/media/1cfe6e43ba69d58e9177565b9f738813/href</a></iframe><h4>LoadableComponent</h4><p>We extended LoadableComponent with our page objects so we get a standardized way of loading pages. See Selenium documentation for more info about <a href="https://github.com/SeleniumHQ/selenium/wiki/LoadableComponent">LoadableComponent</a>.</p><h4>PageFactory</h4><p>Selenium provides a nice <strong>@FindBy</strong> annotation for WebElements which provides improved readability of page objects. For annotations to work we need to use PageFactory to initialize WebElements. Check <a href="https://github.com/SeleniumHQ/selenium/wiki/PageFactory">PageFactory</a> in Selenium docs for detailed examples.</p><p>We will make changes to GoogleTestExample class to use page objects.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e78a79d1481e3742511b109c2c55fde8/href">https://medium.com/media/e78a79d1481e3742511b109c2c55fde8/href</a></iframe><h3>Reports</h3><p>When we invoke the Gradle test task with:</p><pre>./gradlew clean test</pre><p>There is a default Gradle HTML report generated in directory</p><pre>build/reports/tests/test/</pre><h3>Source</h3><p>Source for this example project can be found on <a href="https://github.com/hruhek/ag04-blog-selenium">GitHub</a>.</p><figure><a href="http://bit.ly/MediumAGENCY04"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tquvcAixKbvB7IvqqXTl8Q.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a70c4a9b2d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/agency04/automating-management-of-selenium-webdriver-binaries-with-java-3a70c4a9b2d5">Automating management of Selenium webdriver binaries with Java</a> was originally published in <a href="https://medium.com/agency04">Agency04</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>