首页 > 解决方案 > 如果用户名包含 /,如何在 selenium 中传递基本凭据(代理凭据)

问题描述

我在设置代理的客户端环境中使用硒。每当我打开 chrome 驱动程序时,它都会要求提供凭据。我可以按以下格式传递凭据
String baseurl = " https://username:password@abc.com/Security/Login.asp 但我的用户名有 '/' 并且它不起作用
用户名 = 'account-01/d123456'

代码 :

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches",
Collections.singletonList("enable-automation"));
options.addArguments("--disable-extensions");
options.addArguments("start-maximized");
options.addArguments("disable-infobars");

System.setProperty("webdriver.chrome.driver","./driver/chromedriver.exe");
WebDriver driver= new ChromeDriver(options);
//driver.manage().window().maximize();
String baseurl= "https://account-01/d123456:Rahul%456@abc.com/Security/Login.asp";
driver.get(baseurl);

标签: seleniumselenium-chromedriver

解决方案


推荐阅读