I added implicit wait in SetUp method of Test class and also in Constructor of page object. I need to apply wait for all Test methods. But it doesn't work. Can anyone help pls. I have used NUnit framework
Page Object:
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();
}
}
}
Test class:
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();
}
}
}