[ selenium ] with TestNG and WebDriver

1) TestNG Eclipse Plugin Installation

  1. In eclipse, Help > Install New Software …
  2. Add Repository http://beust.com/eclipse and install

ref : http://toolsqa.com/selenium-webdriver/install-testng/

2) Create TestNG Class

  1. Right click at package, TestNG > create TestNG class
  2. Fill-in classname, we can also check the @BeforeMethod, @AfterMethod annotation
  3. Run : Run As > TestNG Test

ref : http://toolsqa.com/selenium-webdriver/testng-testcase/

3) Add Selenium-java and testNG to Library

selenium-java-testng.png

NOTE : All JARs inside Selenium-java.zip need to be added, otherwise we will got below error.

FAILED CONFIGURATION: @BeforeClass setUpFAILED CONFIGURATION: @BeforeClass setUpjava.lang.NoClassDefFoundError: com/google/common/base/Function at my.my.test.NewTest.setUp(NewTest.java:28)

 

Common Run Error

java.lang.UnsupportedClassVersionError: org/openqa/selenium/NoAlertPresentException : Unsupported major.minor version 52.0

Root Cause

The version of Selenium you have requires Java 8.
You are not running this on Java 8.

ref : https://www.reddit.com/r/learnjava/comments/5jzbjx/javalangunsupportedclassversionerror/

ChromeDriver common error

The path to the driver executable must be set by the webdriver.chrome.driver system property

Solution 

System.setProperty("webdriver.chrome.driver", "C:/Users/phongsathorn.e/Downloads/chromedriver_win32/chromedriver.exe");

driver = new ChromeDriver();

ref : https://stackoverflow.com/questions/44476647/getting-the-path-to-the-driver-executable-must-be-set-by-the-webdriver-chrome-d

Download ChromeDriver.exe at https://sites.google.com/a/chromium.org/chromedriver/downloads

Ref : Download previous version of selenium

http://selenium-release.storage.googleapis.com/index.html

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s