【发布时间】:2016-04-27 16:08:41
【问题描述】:
我正在关注 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/这行代码给我这样的错误
“您必须通过身份验证才能访问此 URL”
状态码=403
确切的错误如下
“OpenQA.Selenium.WebDriverException”类型的异常发生在 WebDriver.dll 但未在用户代码中处理
附加信息:意外错误。
McAfee Web Gateway - 通知 - 身份验证 必填
验证 必需的urlprotocol = "http"; 状态码=403; 如果(状态码==401 && urlprotocol ==“ftp”){<td class="contentData"> You must be authenticated to access this URL. </td>如果您的浏览器没有显示 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\"id=\"ftpUsername\" name=\"ftpUsername\" size=40 />");document.write("<tr><td class=\"contentData\">Username:</td><td><input type=\"text\"id=\"ftpPassword\" name=\"ftpPassword\" size=40 />");document.write("<tr><td class=\"contentData\">Password:</td><td><input type=\"password\"value=\"访问 FTP\" />");document.write("<tr><td class=\"contentData\" colspan=2 align=center><input type=\"button\" onclick=\"redirectToFTP();\"} 函数重定向到FTP(){document.write("</table>"); document.write("</form>");}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>代理:XXXXXXX
规则:验证:NTLM
我刚刚将代理替换为 XXXXXX
我也在使用真正获得完全许可的 Browserstack 帐户用户名/密码,但出于这个问题的目的,这里有示例。 “USERNAME”作为用户名,“ACCESS_KEY”作为密码。
非常感谢任何反馈,谢谢。
【问题讨论】:
-
您需要在 URL 中设置凭据:browserstack.com/automate/java
标签: selenium testing automation browserstack