带有特殊字符的 URL 的用户名和密码的 Windows 身份验证

问题描述 投票:0回答:1

我有一个 URL(姑且称之为

my.url.com
)。我将 Selenium 与 Java 结合使用以实现自动化。此 URL 需要登录名和密码才能登录,但它使用 Windows 登录名/密码,因此 Selenium 无法访问它。我读到我可以做
http://login:[email protected]
。问题是,假设用户是
tony
,密码是
ch@mberlain
。这有一个
@
所以它混淆了网址:

http://tony:ch@[email protected]

我读到你可以逃脱,所以我尝试了一个

http://tony:ch%[email protected]

但这也不管用。

我需要分号之类的东西吗

http://tony:ch%40;[email protected]

或括号

http://tony:ch{%40}[email protected]

左右?我如何让它工作?错误是安全错误。

Failed to navigate to XXXXXX. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed. The error returned is: Received error: 0x800c000e ['A security problem occurred.']

(因为这是一个公司网址,出于保密考虑,我不得不将其删除并替换为 Xs。

my.url.com
只是为了示例)。

知道该怎么办吗?这是运行具有 IE 兼容性的 Edge。更改密码不是一种选择。

java security selenium-webdriver url windows-authentication
1个回答
0
投票

使用Basic Authentication如果Windows登录名/密码包含符号,例如

ch@mberlain
你需要解码/编码string如下:

ch@mberlain -> ch%40mberlain

这个用例

在您的用例中,您需要:

driver.get("http://tony:ch%[email protected]");
© www.soinside.com 2019 - 2024. All rights reserved.