1 回答

TA貢獻1752條經驗 獲得超4個贊
對于您在 Gmail 登錄頁面中輸入的密碼,您可以使用此定位器:By.name("password")并且您似乎需要等待此元素。首先,導入如下:
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
并嘗試以下代碼:
wd.get("https://mail.google.com/mail/u/0/h/1pq68r75kzvdr/?v%3Dlui");
//wait email input
WebElement email = new WebDriverWait(wd, 10).until(ExpectedConditions.elementToBeClickable(By.name("identifier")));
email.sendKeys("[email protected]");
wd.findElement(By.id("identifierNext")).click();
//wait password input
WebElement password = new WebDriverWait(wd, 10).until(ExpectedConditions.elementToBeClickable(By.name("password")));
password.sendKeys("qwerty123");
System.out.println("clicked");
添加回答
舉報