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는 봇이라고 감지하지만 자바스크립트로 붙여넣는 것은 감지 못함

+ Recent posts