gpt4 book ai didi

selenium - Browserstack Selenium 自动化集线器

转载 作者:行者123 更新时间:2023-11-28 21:09:43 28 4
gpt4 key购买 nike

我正在关注 browserstack 的 documentation关于使用自动化并且当前出现错误并且对 URI 有点困惑。

我的代码如下所示:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;

namespace SeleniumTest {
class Program {
static void Main(string[] args) {
IWebDriver driver;
DesiredCapabilities capability = DesiredCapabilities.Firefox();
capability.SetCapability("browserstack.user", "USERNAME");
capability.SetCapability("browserstack.key", "ACCESS_KEY");

driver = new RemoteWebDriver(
new Uri("http://hub.browserstack.com/wd/hub/"), capability
);
driver.Navigate().GoToUrl("http://www.google.com");
Console.WriteLine(driver.Title);

IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Browserstack");
query.Submit();
Console.WriteLine(driver.Title);

driver.Quit();
}
}
}

我对 uri http://hub.browserstack.com/wd/hub/ 感到困惑

我不明白这个 URI 是什么?

为什么需要它?

为什么这行代码 http://hub.browserstack.com/wd/hub/ 给我这样的错误

"You must be authenticated to access this URL"

Status Code=403

具体错误如下

An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code

Additional information: Unexpected error.

McAfee Web Gateway - Notification - Authentication Required

Authentication Required
<td class="contentData">

You must be authenticated to access this URL.

</td>
urlprotocol = "http"; statuscode=403; if(statuscode==401 && urlprotocol == "ftp"){
  document.write("<form name=\"ftpform\" method=\"get\" action=\"\">");

document.write("<table class=\"contentData\">");

document.write("<tr><td class=\"contentData\" colspan=2>Please enter your credentials in the form below and click \"Access FTP\"
button if your browser doesn't present authentication prompt for FTP sites.");
  document.write("<tr><td class=\"contentData\">Username:</td><td><input type=\"text\"
id=\"ftpUsername\" name=\"ftpUsername\" size=40 />");
  document.write("<tr><td class=\"contentData\">Password:</td><td><input type=\"password\"
id=\"ftpPassword\" name=\"ftpPassword\" size=40 />");
  document.write("<tr><td class=\"contentData\" colspan=2 align=center><input type=\"button\" onclick=\"redirectToFTP();\"
value=\"Access FTP\" />");
  document.write("</table>");

document.write("</form>");
} function redirectToFTP(){
  var username=unescape(document.getElementById("ftpUsername").value);

var password=unescape(document.getElementById("ftpPassword").value);

location.href = "ftp://"+username+":"+password+"@hub.browserstack.com:80/wd/hub/session"
}
<td class="infoData">

<b>URL: </b><script type="text/javascript">break_line("http://hub.browserstack.com/wd/hub/session");</script><br />

</td>

Proxy: XXXXXXX

Rule: Authenticate: NTLM


我刚刚用 XXXXXX 替换了代理

我还使用了一个真正的完全许可的 Browserstack 帐户用户名/密码,但出于这个问题的目的,这里有示例。用户名为“USERNAME”,密码为“ACCESS_KEY”。

非常感谢任何反馈,谢谢。

最佳答案

如果您只需将 USERNAMEACCESS_KEY 替换为有效的浏览器堆栈凭据,您的 C# 代码就可以正常运行。如果您仍然收到 403 错误,请仔细检查您的凭据。

通过 browserstack,您可以在 browserstack 管理的机器上远程运行测试,而不是在您自己的机器上本地运行测试。 url http://hub.browserstack.com/wd/hub/ 是您进入 browserstack 的入口点,他们可以通过它验证谁在运行测试,因此您提供了用户名和 access_key。

关于selenium - Browserstack Selenium 自动化集线器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36895243/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com