我不得不做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