我不得不做Saucelabs类似的东西。在我的设置中,我添加了以下内容。您可能需要稍微更改一下,以支持您的框架。我使用SpecFlow。
所以这一点的全部是你传递一个TestName但TestName尚不可用。
这是一个BeforeScenario挂钩,它将启动驱动程序,并且我传递测试名称即“标题”。你需要找出测试名是可用的,然后传递该值。
var Title = ScenarioContext.Current.ScenarioInfo.Title;
Browser.StartSauceDriver(Title);
然后在StartSauceDriver我有标题,我可以使用。
public static void StartSauceDriver(string Title)
{
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability(CapabilityType.BrowserName, System.Environment.GetEnvironmentVariable("SELENIUM_BROWSER"));
caps.SetCapability(CapabilityType.Version, System.Environment.GetEnvironmentVariable("SELENIUM_VERSION"));
caps.SetCapability(CapabilityType.Platform, System.Environment.GetEnvironmentVariable("SELENIUM_PLATFORM"));
caps.SetCapability("name", Title);
_webDriver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com/wd/hub"), caps, TimeSpan.FromSeconds(600));
_wait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(600));
}
你使用的能力是正确的,而在BrowserStack测试。我明白这里唯一的问题是检索测试方法名称。我查了几个在线资源并创建了这个脚本 - https://gist.github.com/ashwingonsalves/4a139fc1ac9824eff07b3898d199c3f4。您可能需要处理这个问题。 –
没有发布我想要的方式,所以会发布为答案。 – Dazed