user3149750
user3149750

Reputation: 17

My created webdriver script gives a exception when execute using TestNG

Im very new to selenium and tried creating a test script in eclipse. When the class is executed using TestNG a testngexception is thrown. can some one please check whether there is a issue with the script I have written?

package first_package;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class Test_Class_Automation {

    @Test
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.get("https://www.google.lk");
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        driver.close();
    }
}

Upvotes: 0

Views: 29

Answers (1)

Priyanshu
Priyanshu

Reputation: 3058

If you are using testng annotation then you don't need to write main method there. You can just write it in this way: package first_package;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class Test_Class_Automation {

    @Test
    public void testCase {
        // TODO Auto-generated method stub
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.get("https://www.google.lk");
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        driver.close();
    }
  }

Upvotes: 1

Related Questions