gpt4 book ai didi

java - Gmail 的密码下一步按钮

转载 作者:行者123 更新时间:2023-11-30 06:12:57 25 4
gpt4 key购买 nike

gmail 的“passwordNext”按钮并不总是有效。显式等待似乎也没有帮助。

public void funcLogin() {      
driver.findElement(LoginMail).sendKeys(prop.getProperty("email"));
driver.findElement(LoginMail).sendKeys(Keys.RETURN);
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(PwdMail).sendKeys(prop.getProperty("passwd"));
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(By.id("passwordNext")).click();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}

错误:

org.openqa.selenium.WebDriverException: unknown error: Element <div role="button" id="passwordNext" class="O0WRkf zZhnYe e3Duub C0oVfc nDKKZc DL0QTb" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;" jsshadow="" jsname="Njthtb" aria-disabled="false" tabindex="0">...</div> is not clickable at point (787, 340). Other element would receive the click: <div class="ANuIbb IdAqtf" jsname="k4HEge" tabindex="0"></div>

最佳答案

您必须正确使用显式等待才能使用该功能:
以下是 Gmail 登录代码,运行良好:

代码

public class QQ_TT {

static WebDriver driver;
static WebDriverWait wait;

public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "D:\\Automation\\chromedriver.exe");
driver = new ChromeDriver();
wait = new WebDriverWait(driver,50);
driver.manage().window().maximize();
driver.get("https://www.gmail.com");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("headingText"))));
driver.findElement(By.id("identifierId")).sendKeys("QQ_TT@gmail.com");
driver.findElement(By.xpath("//span[text()='Next']")).click();
wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("headingText"))));
driver.findElement(By.name("password")).sendKeys("qq_tt@stackoverflow");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Next']")));
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='Next']")));
driver.findElement(By.xpath("//span[text()='Next']")).click();

}

}

如果您对此有任何疑问,请告诉我。

关于java - Gmail 的密码下一步按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49836823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com