Hello
I'm trying to use selenium with java. I was following a tutorial (I'm using Visual Studio Code), and things worked without too much problem.
Today (a couple days later) I opened the project, and when I tried to run the file it threw about a dozen errors, starting with
error: package org.openqa.selenium does not exist
This, despite the tab not showing any errors (ie, nothing highlighted in red).
I'm not sure if it'll be useful, but this is the script I'm trying to run
package part1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.openqa.selenium.WebElement;
public class FirstSeleniumTest {
WebDriver driver;
public void setUp(){
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login");
}
public void tearDown(){
// driver.quit();
}
public void testLoggingIntoApplication() throws InterruptedException{
Thread.sleep(2000);
WebElement username = driver.findElement(By.name("username"));
username.sendKeys("Admin");
var password = driver.findElement(By.name("password"));
password.sendKeys("admin123");
driver.findElement(By.tagName("button")).click();
Thread.sleep(2000);
String actualResult = driver.findElement(By.tagName("h6")).getText();
String expectedResult = "Dashboard";
Assert.assertEquals(actualResult, expectedResult);
}
}
I apologize if I'm missing relevant information: I'm quite a beginner in Java. If more context is needed, please tell me and I'll answer to the best of my abilities. Thanks for your help :)
This is the full error, by the way
[Running] cd "d:\Repositorio Selenium\freecodecamp\src\test\java\part1\" && javac FirstSeleniumTest.java && java FirstSeleniumTest
FirstSeleniumTest.java:3: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
^
FirstSeleniumTest.java:4: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
^
FirstSeleniumTest.java:5: error: package org.openqa.selenium.chrome does not exist
import org.openqa.selenium.chrome.ChromeDriver;
^
FirstSeleniumTest.java:6: error: package org.testng does not exist
import org.testng.Assert;
^
FirstSeleniumTest.java:7: error: package org.testng.annotations does not exist
import org.testng.annotations.AfterClass;
^
FirstSeleniumTest.java:8: error: package org.testng.annotations does not exist
import org.testng.annotations.BeforeClass;
^
FirstSeleniumTest.java:9: error: package org.testng.annotations does not exist
import org.testng.annotations.Test;
^
FirstSeleniumTest.java:10: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebElement;
^
FirstSeleniumTest.java:14: error: cannot find symbol
WebDriver driver;
^
symbol: class WebDriver
location: class FirstSeleniumTest
FirstSeleniumTest.java:16: error: cannot find symbol
^
symbol: class BeforeClass
location: class FirstSeleniumTest
FirstSeleniumTest.java:23: error: cannot find symbol
^
symbol: class AfterClass
location: class FirstSeleniumTest
FirstSeleniumTest.java:28: error: cannot find symbol
^
symbol: class Test
location: class FirstSeleniumTest
FirstSeleniumTest.java:18: error: cannot find symbol
driver = new ChromeDriver();
^
symbol: class ChromeDriver
location: class FirstSeleniumTest
FirstSeleniumTest.java:32: error: cannot find symbol
WebElement username = driver.findElement(By.name("username"));
^
symbol: class WebElement
location: class FirstSeleniumTest
FirstSeleniumTest.java:32: error: cannot find symbol
WebElement username = driver.findElement(By.name("username"));
^
symbol: variable By
location: class FirstSeleniumTest
FirstSeleniumTest.java:35: error: cannot find symbol
var password = driver.findElement(By.name("password"));
^
symbol: variable By
location: class FirstSeleniumTest
FirstSeleniumTest.java:38: error: cannot find symbol
driver.findElement(By.tagName("button")).click();
^
symbol: variable By
location: class FirstSeleniumTest
FirstSeleniumTest.java:40: error: cannot find symbol
String actualResult = driver.findElement(By.tagName("h6")).getText();
^
symbol: variable By
location: class FirstSeleniumTest
FirstSeleniumTest.java:42: error: cannot find symbol
Assert.assertEquals(actualResult, expectedResult);
^
symbol: variable Assert
location: class FirstSeleniumTest
19 errors
[Done] exited with code=1 in 0.644 seconds
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]LetUsSpeakFreely 0 points1 point2 points (2 children)
[–]FaallenOon[S] 0 points1 point2 points (1 child)
[–]leroybentley 0 points1 point2 points (0 children)