有没有人有在Browserstack中运行Selenium C#测试的经验。从Browserstack中试用这个例子,但我似乎无法在Visual Studio中对Test explorer进行测试。不知道为什么我不能执行测试。有任何想法吗?我在Visual Studio中运行本地测试没有问题。
RandomAccessIterator
答案 0 :(得分:0)
尝试更改此行:
driver = new RemoteWebDriver(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability
要
driver = new RemoteWebDriver(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability, TimeSpan.FromSeconds(600));
如果这不起作用,请调试它并找出失败的地方,以便我们缩小范围。您正在使用用户和密钥正确吗?
答案 1 :(得分:0)
using System;
using System.Security.Policy;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
namespace SeleniumTest
{
[TestClass]
class Program
{
[TestMethod]
public void Test()
{
IWebDriver driver;
DesiredCapabilities capability = DesiredCapabilities.Chrome();
capability.SetCapability("browserName", "iPad");
capability.SetCapability("platform", "MAC");
capability.SetCapability("device", "undefined");
capability.SetCapability("browserstack.user", "");
capability.SetCapability("browserstack.key", "");
driver = new RemoteWebDriver(
new Uri("http://hub-cloud.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();
}
}
}
**Change the add this code and try to check it by adding in empty Unit test class
file**