我在 Test 类的 SetUp 方法和页面对象的构造函数中添加了隐式等待。我需要申请等待所有测试方法。但它不起作用。任何人都可以帮忙吗?我用过 NUnit 框架
页面对象:
namespace ProjectName.PageObjects
{
class SearchPage
{
IWebDriver driver;
public SearchPage(IWebDriver driver)
{
this.driver = driver;
PageFactory.InitElements(driver, this);
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(40);
}
[FindsBy(How = How.XPath, Using = "//a[text()='Search']")]
IWebElement search;
public void SearchClick()
{
search.Click();
}
}
}
测试类:
namespace ProjectName
{
class SearchTestClass
{
IWebDriver driver;
SearchPage search;
[SetUp]
public void SetUp()
{
driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(40);
//Go to URL
//Login
}
[Test]
public void SearchTest()
{
search.SearchClick();
}
}
}