You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
namespace TestAutomation.Utils; |
|
|
|
public class Website { |
|
public Website(IWebDriver webDriver) { |
|
WebDriver = webDriver; |
|
|
|
HarassCalculatorPage = new HarassCalculatorPage(this); |
|
} |
|
|
|
public IWebDriver WebDriver { get; } |
|
|
|
public HarassCalculatorPage HarassCalculatorPage { get; } |
|
|
|
public IWebElement Find(string byId) { |
|
return WebDriver.FindElement(By.Id(byId)); |
|
} |
|
|
|
public IList<IWebElement> FindChildren(string ofId, string tagname) { |
|
return WebDriver.FindElements(By.CssSelector($"#{ofId} {tagname}")); |
|
} |
|
|
|
public string FindText(string byId) { |
|
return WebDriver.FindElement(By.Id(byId)).Text; |
|
} |
|
|
|
|
|
public int FindInt(string byId) { |
|
return int.Parse(WebDriver.FindElement(By.Id(byId)).Text); |
|
} |
|
|
|
|
|
public IWebElement EnterInput<T>(IWebElement element, T input) { |
|
element.Clear(); |
|
element.SendKeys(input!.ToString()); |
|
element.SendKeys(Keys.Enter); |
|
return element; |
|
} |
|
|
|
|
|
public IWebElement EnterInput<T>(string byId, T input) { |
|
var element = Find(byId); |
|
element.Clear(); |
|
element.SendKeys(input!.ToString()); |
|
element.SendKeys(Keys.Enter); |
|
return element; |
|
} |
|
|
|
public string GetLabel(string byId) { |
|
return Find(byId).Text; |
|
} |
|
} |