我目前正在尝试使用最新版本的Selenium来自动化网站的登录身份验证过程。在我运行代码的时候,它似乎没有填满任何东西。
package browserTest;
import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.security.UserAndPassword;
public class browserRunThrough
{
public static void main(String[] args)
{
WebDriver driver1 = new FirefoxDriver();
driver1.get("URL");
Alert alert = driver1.switchTo().alert();
alert.authenticateUsing(new UserAndPassword("username","password"));
}
}
编辑:不填写任何东西我的意思是我到了网址但它没有填写用户名或密码
答案 0 :(得分:1)
尝试添加WebDriverWait:
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword("username","password"));
您也可以使用autoit。
答案 1 :(得分:-1)
请检查firefox vesion是否与selenium webdriver版本匹配。 另外请确保您已正确配置firefox的设置。