Reputation: 112
I have issue in my selenium script might be issue in Eclipse i tryed all possible aspect with adding all JAR library with different version but i faild to run script expert please look where i stuck
package Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Test {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "https://www.facebook.com/";
driver.get(baseUrl);
WebElement email = driver.findElement(By.id("email"));
WebElement password = driver.findElement(By.id("pass"));
WebElement login = driver.findElement(By.xpath("//*[@id='loginbutton']"));
email.sendKeys("[email protected]");
password.sendKeys("abcd123");
login.click();
System.out.println("Login Done with Click");
}
}
Error :
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
WebDriver cannot be resolved to a type
at Test.Test.main(Test.java:15)
This is my JAR library structure:
Upvotes: 0
Views: 3012
Reputation: 193108
This error message...
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
WebDriver cannot be resolved to a type
...implies that there were compilation issues in your program.
It is pretty evident from the snapshot you are using Selenium v3.6.0 but I don't see any error as such in your code block. However you can follow the below mentioned steps to solve the issue:
Test
and the Class name i.e. Test
needs to be different. You can't use the same name for the package and the class.You can find a couple of relevant discussions in:
Upvotes: 1
Reputation: 3131
You need selenium-java
on your classpath. The latest version at time of writing is 3.141.59.
selenium-java 3.141.59 (direct download)
Upvotes: 0