栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

对此进行了一些更新

link


Chromium Issue435547

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

我们应该阻止对包含嵌入式凭据(例如“ http://
ima_user:hunter2@example.com/yay.tiff

”)的子资源的请求。这些资源将作为网络错误处理。

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

这是示例代码,它尝试使用一组有效的凭据打开URL http://the-internet.herokuapp.com/basic_auth ,并且可以正常工作。

Firefox:

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");    }}

Chrome:

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");    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/447811.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号