파이썬과 같이 크롬 웹드라이버 실행 파일을 따로 설치하지 않고 아래의
웹드라이버 매니저 JAR 설치
https://jar-download.com/artifact-search/webdrivermanager
Download webdrivermanager JAR file with all dependencies
io.github.bonigarcia webdrivermanager 5.6.3 compile group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.6.3' //Thanks for using https://jar-download.com libraryDependencies += "io.github.bonigarcia" % "webdrivermanager" % "5.6.3" //Thanks
jar-download.com
vscode에서 왼쪽하단의 레퍼런스 라이브러리에서 다운받은 웹드라이버 추가한다.
https://www.selenium.dev/downloads/에서 자바용 셀레니움을 받고 위에서 처럼 추가해 준다(라이브러리의 모든 JAR를 임포트해야 에러가 없음)
Downloads
Selenium automates browsers. That's it!
www.selenium.dev
아래와 같이 간단히 테스트 해본다.
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
// WebDriverManager.chromedriver().setup();
ChromeDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
}
}
'프로그래밍 > 자바' 카테고리의 다른 글
자바에서 파이썬 파일 실행하고 결과 받아 오기 (0) | 2024.02.09 |
---|---|
[자바] sleep함수 (0) | 2024.02.09 |
자바에서 javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake (0) | 2024.02.08 |
자바로 RSI 구하기 (0) | 2024.02.06 |
java.net.BindException: Address already in use: bind 에러 (1) | 2023.12.26 |