Selenium - Basic Authentication via url

后端 未结 5 2039
时光说笑
时光说笑 2020-11-22 01:02

In my Selenium-Test (with chromedriver-2.24) I\'m trying to access my webpage via basic authentication with the following statement:



        
5条回答
  •  再見小時候
    2020-11-22 01:14

    The basic authentication via url is blocked only for sub resources. So you could still use it on the domain:

    driver.get("http://admin:admin@localhost:8080");
    driver.get("http://localhost:8080/project");
    

    You could also create a small extension to automatically set the credentials when they are requested:

    options = webdriver.ChromeOptions()
    options.add_extension(r'C:\dev\credentials.zip')
    

    https://gist.github.com/florentbr/25246cd9337cebc07e2bbb0b9bf0de46

提交回复
热议问题