Friday, July 13, 2018

Prerequisite for the First Test Case using Selenium WebDriver

Using Selenium WebDriver, we can test web applications against different browsers, such as Google Chrome, Mozilla Firefox, Internet Explorer and so on. You can find all supported browsers from here.

Before we start writing our first test case, there are several things we need to set up. We are going to use the latest version 3.13.0.

1) Download Web Drivers for each browser.
     In this article, we are going to test on three browsers, Google Chrome, Mozilla Firefox, and Internet Explorer. You can find web drivers from selenium website here. And download web driver zip file for each browser. And unzip all files into a folder in your machine.
    There should be three executable files in the folder after finished download, chromedriver.exe, geckodriver.exe, and IEDriverServer.exe.

2) Set property in Environment Variables
     In order to start web driver successfully, we need to enable these web drivers. The first option is to setup system environment variables in your machine.
     Open the "Environment Variables" from the Control Panel and add a new item into "Path", in this example the path is "D:\selenium-drivers", which is the location of web driver files.

      The second option is to config library path through System.setProperty function in the test case.
       System.setProperty("webdriver.chrome.driver", "Path to chromedriver.exe");
       System.setProperty("webdriver.gecko.driver", "Path to geckodriver.exe");
       System.setProperty("webdriver.ie.driver", "Path to IEDriverServer.exe");

       After we have done this, selenium should be able to find the web driver.

3) Enable protected mode for Internet Explorer
    You may find NoSuchElement exception when executing the test case on Internet Explorer. That probably you haven't enable protected mode in your IE settings.
     Open "Security" tab in "Internet Options", and check the Enable Protected Mode check-box. And make sure you have done this for all zones.

4) Using Win32 web driver for Internet Explorer
     You may find it slow to send a value to the input element when executing the test case on Internet Explorer. Try to download Win32 web driver.


No comments:

Post a Comment