无法在Google中键入密码使用selenium登录

时间:2018-03-18 10:44:04

标签: java google-chrome selenium selenium-webdriver google-signin

无法在google中使用selenium

键入密码
public class FirtsTest extends WebDriverSettings {

    @Test
    public void  firstTest() {
        driver.get("https://www.google.com.ua/");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        WebElement SignInButton = driver.findElement(By.id("gb_70"));
        SignInButton.click();
        WebElement Login = driver.findElement(By.id("identifierId"));
        Login.clear();
        Login.sendKeys("angelslayer1995");
        WebElement NextButton = driver.findElement(By.id("identifierNext"));
        NextButton.click();
        WebElement PasswordInput = driver.findElement(By.cssSelector("input[type='password']"));
        WebDriverWait wait = new WebDriverWait(driver,20);
        wait.until(ExpectedConditions.elementToBeClickable(PasswordInput));
        PasswordInput.clear();
        PasswordInput.sendKeys("02091995");
    }
}

1 个答案:

答案 0 :(得分:0)

Google对每个定位器进行加密,以防止使用脚本进行自动输入。您不应尝试自动登录,您的IP将立即被列入黑名单。