2025-02-15 19:42:01 +04:00
|
|
|
|
using OpenQA.Selenium.Support.UI;
|
|
|
|
|
using OpenQA.Selenium;
|
|
|
|
|
using SeleniumExtras.WaitHelpers;
|
|
|
|
|
|
|
|
|
|
namespace TestProject
|
|
|
|
|
{
|
|
|
|
|
public class BasePage
|
|
|
|
|
{
|
|
|
|
|
protected IWebDriver driver;
|
|
|
|
|
|
|
|
|
|
public BasePage(IWebDriver driver)
|
|
|
|
|
{
|
|
|
|
|
this.driver = driver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IWebElement FindElement(By locator)
|
|
|
|
|
{
|
|
|
|
|
return driver.FindElement(locator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Type(By locator, string text)
|
|
|
|
|
{
|
|
|
|
|
WaitUntilElementIsVisible(locator);
|
|
|
|
|
FindElement(locator).Clear();
|
|
|
|
|
FindElement(locator).SendKeys(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Click(By locator)
|
|
|
|
|
{
|
|
|
|
|
WaitUntilElementIsVisible(locator);
|
|
|
|
|
FindElement(locator).Click();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void WaitUntilElementIsVisible(By locator, int time = 100)
|
|
|
|
|
{
|
|
|
|
|
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(time));
|
2025-02-15 23:11:44 +04:00
|
|
|
|
wait.Until(ExpectedConditions.ElementToBeClickable(locator));
|
2025-02-15 19:42:01 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenUrl(string url)
|
|
|
|
|
{
|
|
|
|
|
driver.Navigate().GoToUrl(url);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|