如何使用chrome驱动程序在Java中使用Java重写selenium2中的基本身份验证? [英] How to override basic authentication in selenium2 with Java using chrome driver?

查看:371
本文介绍了如何使用chrome驱动程序在Java中使用Java重写selenium2中的基本身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何覆盖selenium2 chrome驱动程序中的基本身份验证?
我在我的项目中遇到了一个问题,Chrome需要身份验证弹出窗口,阻止webdriver继续导航。
请查找相同的附件截图。
我使用下面的代码来实例化chrome驱动程序, p>

 私人WebDriver驱动程序; 
@Override
保护无效setUp()抛出异常{
super.setUp();
System.setProperty(webdriver.chrome.driver,C:/Selenium/chromedriver.exe);
driver = new ChromeDriver();
}
@Override
保护无效tearDown()抛出异常{
// TODO自动生成的方法存根
super.tearDown();
}

请帮忙 -

感谢,

em> windows集成身份验证)而不是基本身份验证(您可以在URL中提供凭据)。假设您可以尝试在Chrome中运行NTML身份验证:

方法1



转到Internet资源管理器,并打开Internet选项。按照以下步骤操作:




  • 将您的网站添加到本地Intranet或可信站点







完成这些更改后,您的chrome身份验证应该工作。如果您想知道IE设置如何影响Chrome浏览器的行为,那么Chrome会使用IE安全设置进行身份验证。



一些优秀的资源/信用:


  1. 详细信息

  2. Selenium issue details



  3. 方法2



    将您的网站添加到本地Intranet ,并且不要更改任何用于用户身份验证的内容。默认情况下,选择第二个选项(只在Intranet站点自动登录)。


    How to override basic authentication in selenium2 chrome driver? I am facing an issue in my project where chrome "Authentication required" popup is coming which is blocking webdriver to continue navigation. Please find the attached screenshot for the same. I am using following code to instantiate chrome driver,

    private WebDriver driver;
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        System.setProperty("webdriver.chrome.driver", "C:/Selenium/chromedriver.exe");
        driver = new ChromeDriver();
    }
    @Override
    protected void tearDown() throws Exception {
        // TODO Auto-generated method stub
        super.tearDown();
    }
    

    Could you please help -

    Thanks,

    解决方案

    I think you're talking about using NTLM Authentication (windows integrated authentication) not Basic Authentication (where you provider your credentials in URL). Assuming that here is what you can try for running NTML auth in chrome:

    Approach 1

    Go to Internet Explorer, and open "Internet Options". Follow following steps:

    • Add your site to either Local intranet or Trusted sites

    After these changes, your chrome authentication should work. If you're wondering that how IE settings effect chrome behavior then, Chrome uses IE security settings for authentication.

    Some good resources / credits:

    1. Good details
    2. Selenium issue details

    Approach 2

    Add your site to Local intranet and don't change anything for user authentication. By default, second option (Automatic logon only in Intranet sites) is selected.

    这篇关于如何使用chrome驱动程序在Java中使用Java重写selenium2中的基本身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆