1/02/2018

Set up NetBeans IDE for Selenium test automation (Firefox browser and Java)

Update: There is a community project ojdkbuild which provides Windows installers for OpenJDK.

1. Download selenium-server-standalone from: http://www.seleniumhq.org/download/

2. Download Gecko driver from: https://github.com/mozilla/geckodriver  and store it in some folder, for example: C:\tools\web-drivers\

3. Run NetBeans IDE

4. File > New Project


5. Click Next, enter project name and select project location, then click Finish:






6. Mouse right click > Properties:



7.  Properties > Add Library:


8. Click Create button > enter Library name > OK:






9. Click Add JAR/Folder => select the selenium-server-standalone jar-file



10. Click OK and see new added library:


11. Click Add Library and see:



12. Click OK and see:


13. File > New File > Select Java Class



14. Click Next and enter class name and package name:


15. Use a very simple example, without any test framework (i.e. TestNG or JUnit) and without any assertion library (i.e. Hamcrest):

package com.blogspot.autoqalab;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SeleniumFirstTest {
    static WebDriver driver;
    public static void main(String[] args) {
        
        // set up system property to use Gecko driver
        System.setProperty("webdriver.gecko.driver",
                "C:\\tools\\web-drivers\\geckodriver-v0.19.1\\geckodriver.exe");
        driver = new FirefoxDriver();
        driver.get("https://automation-playground.blogspot.com");

        // get result
        Boolean result;
        try {
            result = verifyTitle();
        } catch (Exception e) {
            result = false;
        } finally {
            driver.close();
        }
        
        // print result
        System.out.println("Test " + (result ? "passed." : "failed."));
        if (!result) {
            System.exit(1);
        }
    }
    private static Boolean verifyTitle() {
        return driver.getTitle().equalsIgnoreCase("Automation Playground");
    }
}

16. Click Run Project button (or F6) to execute the following test scenario:


Test passed !

No comments:

Post a Comment

Visual Studio Code, WebdriverIO, JavaScript and Chrome - cucumber html test report

 Apart Allure test report  we can use Cucumber test report in html format. We will follow this instructions . 1. Install  wdio-cucumberjs-js...