您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

selenium-通过网址进行基本身份验证

selenium-通过网址进行基本身份验证

对此进行了一些更新

在子资源请求中放弃对嵌入式凭据的支持。(已删除

我们应该阻止对包含嵌入式凭据(例如“ http://ima_user:hunter2@example.com/yay.tiff ”)的子资源的请求。这些资源将作为网络错误处理。

但是, 功能仍可通过 Selenium-Java 绑定与 Selenium 3.4.0geckodriver v0.18.0chromedriver v2.31.488763Google Chrome 60.xMozilla Firefox 53.0一起 使用。 __

这是示例代码,它尝试使用一组有效的凭据打开URL ,并且可以正常工作。

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class BasicAuthentication_FF 
{
    public static void main(String[] args) 
    {
        System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
        WebDriver driver =  new FirefoxDriver();
        driver.navigate().to("http://admin:admin@the-internet.herokuapp.com/basic_auth");
    }
}
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class BasicAuthentication_Chrome 
{
    public static void main(String[] args) 
    {
        System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("start-maximized");
        options.addArguments("disable-infobars");
        options.addArguments("--disable-extensions");
        WebDriver driver =  new ChromeDriver(options);
        driver.navigate().to("http://admin:admin@the-internet.herokuapp.com/basic_auth");
    }
}
其他 2022/1/1 18:17:05 有590人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶