Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created February 19, 2017 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/ee92aac75616a3294f2d13c851f05e0a to your computer and use it in GitHub Desktop.
Save angelovstanton/ee92aac75616a3294f2d13c851f05e0a to your computer and use it in GitHub Desktop.
public class BingMainPage
{
private readonly IWebDriver driver;
private readonly string url = @"http://www.bing.com/";
public BingMainPage(IWebDriver browser)
{
this.driver = browser;
PageFactory.InitElements(browser, this);
}
public string Url => @"http://www.bing.com/";
[FindsBy(How = How.Id, Using = "sb_form_q")]
public IWebElement SearchBox { get; set; }
[FindsBy(How = How.Id, Using = "sb_form_go")]
public IWebElement GoButton { get; set; }
[FindsBy(How = How.Id, Using = "b_tween")]
public IWebElement ResultsCountDiv { get; set; }
public void Navigate() => this.driver.Navigate().GoToUrl(this.url);
public void Search(string textToType)
{
this.SearchBox.Clear();
this.SearchBox.SendKeys(textToType);
this.GoButton.Click();
}
public void AssertResultsCount(string expectedCount) => Assert.AreEqual(this.ResultsCountDiv.Text, expectedCount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment