【问题标题】:Java Selenium Authentication IssueJava Selenium 身份验证问题
【发布时间】:2016-01-12 18:45:09
【问题描述】:

我目前正在尝试使用最新版本的 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"));

    }
}

编辑:我的意思是我没有填写任何东西,但它没有填写用户名或密码

【问题讨论】:

    标签: java selenium selenium-webdriver automation


    【解决方案1】:

    尝试添加 WebDriverWait :

     WebDriverWait wait = new WebDriverWait(driver, 10);
     Alert alert = wait.until(ExpectedConditions.alertIsPresent());
     alert.authenticateUsing(new UserAndPassword("username","password"));
    

    您也可以使用autoit

    【讨论】:

      【解决方案2】:

      请检查 firefox 版本是否与 selenium webdriver 版本匹配。 另外请确保您已经正确配置了firefox的设置。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-23
        • 2015-08-25
        相关资源
        最近更新 更多