我想執行一些nunit/C#測試。我正在瀏覽器上使用webdriver進行測試。我想要做的是按照幾個平臺和幾個設備的順序執行我的測試。我試着用[TestFixture(「android」,「Android」,「LG Nexus 4」)] [TestFixture(「android」,「Samsung Galaxy S III」)]和我的類的構造函數。但它不起作用。你能幫我在這裏嗎?在nunit中按順序執行測試
[TestFixture("android", "Android", "LG Nexus 4")]
[TestFixture("android", "Samsung Galaxy S III")]
public class Multi
{
private IWebDriver driver;
private string _browsername;
private string _platform;
private string _device;
public void Multi(string browsername, string platform, string device)
{
_browsername = browsername;
_platform = platform;
_device = device;
}
[SetUp]
public void Init()
{
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("browserstack.user", "test");
capability.SetCapability("browserstack.key", "test");
capability.SetCapability("browserstack.local", "true");
capability.SetCapability("browserName", _browsername);
capability.SetCapability("platform", _platform);
capability.SetCapability("device", _device);
driver = new RemoteWebDriver(
new Uri("http://hub.browserstack.com/wd/hub/"), capability
);
driver.Navigate().GoToUrl("http://sunet.se");
}
[Test]
public void StartTest()
{
Thread.Sleep(5000);
driver.FindElement(By.XPath("/html/body/div[2]/div/div/div[1]/div[1]/div[2]/div/div[1]/div/div/div[2]/div/a")).Click();
}
}
[TestFixtureTearDown]
public void Cleanup()
{
driver.Quit();
}
}
好吧,好像我會被重複的代碼卡住。但現在沒關係。謝謝你的回答。 – user3624378 2014-09-02 09:18:52