好吧,我有一种方法使用硒和c#登录到网站,名为LoginAndSelectAutomationFleet,但是当我运行它时,我得到了一个例外:
microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.TestFailedException: Only data driven test methods can have parameters. Did you intend to use [DataRow] or [DynamicData]?
我所做的就是通过try and catch将方法转换为测试方法。这是代码:
[TestMethod]
public void LoginAndSelectAutomationFleet(IWebDriver driver)
{
// login the user
_userSetRepo = new UserSetttingsRep(driver);
_regRep = new UserRegRep(driver);
objCommon = new clsCommon(driver);
objCommon.loginVT(driver);
string getTitle = driver.Title;
try
{
Assert.IsTrue(getTitle == "Amazing Power");
Console.WriteLine("The application " + getTitle + " has logged in successfully!");
}
catch(Exception ex)
{
Assert.Fail(ex.Message);
Console.WriteLine("The user failed to log in successfully!");
}
System.Threading.Thread.Sleep(3000);
WebDriverWait wait = new WebDriverWait(driver,TimeSpan.FromSeconds(60));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeclickable(By.XPath("//span[text()='User']"))).Click();
WebDriverWait wait1 = new WebDriverWait(driver,TimeSpan.FromSeconds(60));
wait1.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//a[@class='vt-navbar__child-menu-link']//input")));
objCommon.SendKeysAndClickTab(_userSetRepo.inputOrgansiation,"Companyxyz",driver);
}
如何解决?