JavascriptExecutor

import java.util.List;
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;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Exam04 {
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
WebDriver driver = new ChromeDriver();
// WebDriverWait wait = new WebDriverWait(driver,10);
JavascriptExecutor js = (JavascriptExecutor)driver;
driver.get("https://nid.naver.com/nidlogin.login?mode=form&url=https%3A%2F%2Fwww.naver.com");
WebElement idBox = driver.findElement(By.id("id"));
WebElement pwBox = driver.findElement(By.id("pw"));
js.executeScript("arguments[0].value=arguments[1]", idBox, Account.nid);
js.executeScript("arguments[0].value=arguments[1]", pwBox, Account.npw);
// idBox에다가 ABCD를 value값으로 넣어라
// 빠른 타이핑이 아니라 붙여넣는 효과
// send key는 봇이라고 감지하지만 자바스크립트로 붙여넣는 것은 감지 못함
driver.findElement(By.id("log.login")).click();
Thread.sleep(5000);
driver.close();
}
}
js.executeScript("arguments[0].value=arguments[1]", idBox, Account.nid);
idBox에다가 ABCD를 value값으로 넣어라 빠른 타이핑이 아니라 붙여넣는 효과
send key는 봇이라고 감지하지만 자바스크립트로 붙여넣는 것은 감지 못함
'디지털 컨버전스 > Selenium' 카테고리의 다른 글
| [Selenium] 이미지 로딩 제거 (0) | 2020.04.22 |
|---|---|
| [Selenium] iframe - 내게쓰기 입력 (0) | 2020.04.22 |
| [Selenium] 명시적 대기 (0) | 2020.04.22 |
| [Selenium] id값을 모르는 경우 선택하기 (0) | 2020.04.21 |
| [Selenium] sendKeys - 로그인 (0) | 2020.04.21 |