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.

4
  • 3
    You have to import them.CommentedJun 24, 2020 at 18:48
  • 1
    And as a side note, please don't post pictures of code. Post the actual code instead.CommentedJun 24, 2020 at 18:50
  • import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome.ChromeDriver;CommentedJun 24, 2020 at 18:51
  • The import org.openqa cannot be resolved. I'm still getting this error.I can't importCommentedJun 24, 2020 at 20:27

2 Answers 2

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

1
  • The import org.openqa cannot be resolved. I'm still getting this error.CommentedJun 24, 2020 at 20:26
-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

3
  • Please post code as text, not as pictures.CommentedJun 24, 2020 at 18:59
  • The import org.openqa cannot be resolved. I'm still getting this error.CommentedJun 24, 2020 at 20:28
  • Did u import selenium jars to eclipse. If not pls watch this youtu.be/7yYDOja8n_k
    – Satish A
    CommentedJun 24, 2020 at 20:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.