Update: There is a community project ojdkbuild which provides Windows installers for OpenJDK.
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:
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:
- run Firefox browser
- go to https://automation-playground.blogspot.com
- verify the blog's title
- close Firefox browser
Test passed !
No comments:
Post a Comment