0

I'm new to selenium and I tried to code my first java script using selenium.

enter image description here

It is giving errors as follows:

**- WebDriver cannot be resolved to a type

  • ChromeDriver cannot be resolved to a type
  • Watchpoint:FirstSelleniumScript [access and modification] - driver**

I have added selenium to the libaries- selenium-java-3.141.59

java version "1.8.0_251"

I can't understand how to fix it.

Malsha Madushani
  • 27
  • 1
  • 3
  • 11

2 Answers2

0

Import Necessary Files

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

Download The Compatible ChromeDriver

Now in function you have set the path for chromedriver in your method

String chromePath = "C:/Common_Resourses/";
System.setProperty("webdriver.chrome.driver", chromePath + "chromedriver.exe");
WebDriver driver = new ChromeDriver();

You can also Read more About browser capabilities, it will help you with browser handling

-2

You need to set property first and import chrome driver.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class TestChrome {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");
// Initialize browser
WebDriver driver=new ChromeDriver();

Also refer this video https://youtu.be/c86GdHQaLsY

Satish A
  • 83
  • 6