Search

์ž๋™ ๋กœ๊ทธ์ธ ํ”„๋กœ๊ทธ๋žจ

์ž๋™ ๋กœ๊ทธ์ธ ํ”„๋กœ๊ทธ๋žจ

๋„ค์ด๋ฒ„์— ์ž๋™๋กœ๊ทธ์ธ ํ•˜๋Š” ์ฝ˜์†” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค์–ด ๋ด…๋‹ˆ๋‹ค.
1.
ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
2.
๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€ํ•˜๊ธฐ
a.
Selenium
b.
Lombok
3.
์ฝ”๋”ฉ
4.
ํ”„๋กœ์ ํŠธ ๋ฐฐํฌ
5.
์‹คํ–‰

ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

VS CODE

1.
๋ช…๋ น ํŒ”๋ ˆํŠธ (ctrl + shift + P)
2.
Java: Create Java Projectโ€ฆ
a.
No Build Tool
b.
Select this project location
c.
Input a Java project name : AutoLogin
i.
ํ”„๋กœ์ ํŠธ๋ช… : AutoLogin ์ž…๋ ฅ

Java: Create Java Projectโ€ฆ

No Build Tool

Select this project location

Input a Java project name : AutoLogin

1.
ํ”„๋กœ์ ํŠธ๋ช… : AutoLogin ์ž…๋ ฅ

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€ํ•˜๊ธฐ

VSCODE

VSCODE ์—์„œ ์ƒ์„ฑํ•œ Java Project ์— ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•  ๋•Œ๋Š” ํ”„๋กœ์ ํŠธ ์•„๋ž˜ lib ํด๋”์— .jar ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

ํ•„์š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

์•„๋ž˜ ํ•„์š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์•„ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
1.
Selenium
2.
Lombok

Selenium

Selenium์€ ์›น ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ž๋™ํ™”ํ•˜๋Š” ๋„๊ตฌ๋กœ, ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ํ…Œ์ŠคํŠธ ์ž๋™ํ™”์— ๋„๋ฆฌ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์›น ํŽ˜์ด์ง€์˜ ์š”์†Œ๋ฅผ ์ฐพ๊ณ , ํด๋ฆญํ•˜๊ณ , ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋Š” ๋“ฑ์˜ ์ž‘์—…์„ ์ž๋™ํ™”ํ•  ์ˆ˜ ์žˆ์–ด ๋ฐ˜๋ณต์ ์ธ ์›น ์ž‘์—…์„ ํšจ์œจ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์—ฌ๊ธฐ์„œ ์‚ฌ์šฉํ•  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฆฌ์ŠคํŠธ์ž…๋‹ˆ๋‹ค.
โ€ข
commons-exec
โ€ข
failureaccess
โ€ข
guava
โ€ข
selenium-api
โ€ข
selenium-chrome-driver
โ€ข
selenium-chromium-driver
โ€ข
selenium-devtools-vxx
โ€ข
selenium-http
โ€ข
selenium-java
โ€ข
selenium-json
โ€ข
selenium-manager
โ€ข
selenium-os
โ€ข
selenium-remote-driver
โ€ข
selenium-support

Lombok

Lombok์€ Java ๊ฐœ๋ฐœ์—์„œ ๋ฐ˜๋ณต์ ์ธ ์ฝ”๋“œ ์ž‘์„ฑ์„ ์ค„์—ฌ์ฃผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค. Getter, Setter, Constructor ๋“ฑ์„ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•ด์ฃผ์–ด ๊ฐœ๋ฐœ ์ƒ์‚ฐ์„ฑ์„ ํฌ๊ฒŒ ํ–ฅ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค.

์ฝ”๋”ฉ

module-info.java

module AutoLogin { requires org.seleniumhq.selenium.api; requires org.seleniumhq.selenium.chrome_driver; }
Java
๋ณต์‚ฌ

Main.java

package login; import java.util.Scanner; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class Main { public static WebDriver driver = new ChromeDriver(); public static void main(String[] args) { // ํฌ๋กฌ์—์„œ ๋„ค์ด๋ฒ„ ์‹คํ–‰ํ•˜๊ธฐ driver.get("https://nid.naver.com/nidlogin.login"); Scanner sc = new Scanner(System.in); System.out.print("์•„์ด๋”” : "); String id = sc.nextLine(); System.out.print("๋น„๋ฐ€๋ฒˆํ˜ธ : "); String pw = sc.nextLine(); // ์•„์ด๋””/๋น„๋ฒˆ ์ž…๋ ฅ JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.getElementById('id').value='" + id + "'"); js.executeScript("document.getElementById('pw').value='" + pw + "'"); // ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ํด๋ฆญ WebElement loginButton = driver.findElement(By.id("log.login")); loginButton.click(); sc.close(); } }
Java
๋ณต์‚ฌ

ํ”„๋กœ์ ํŠธ ๋ฐฐํฌ

๋ฐฐํฌ๋ž€?
๋ฐฐํฌ๋Š” ๊ฐœ๋ฐœํ•œ ํ”„๋กœ๊ทธ๋žจ์„ ์‚ฌ์šฉ์ž๊ฐ€ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ํŒจํ‚ค์ง•ํ•˜๊ณ , ์ด๋ฅผ ๋ฐฐํฌ ๊ฐ€๋Šฅํ•œ ํ˜•ํƒœ๋กœ ์ œ๊ณตํ•˜๋Š” ๊ณผ์ •์ž…๋‹ˆ๋‹ค.
โ€ข
VS CODE
โ€ข
Eclipse

VS CODE

(์ž‘์„ฑ์ค‘ โ€ฆ)

Eclipse

1.
ํ”„๋กœ์ ํŠธ ์šฐํด๋ฆญ
2.
Export
3.
Java
a.
Runnable JAR File

์‹คํ–‰