Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created July 9, 2017 21: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/d999032642e1404c1128e39f24f6e109 to your computer and use it in GitHub Desktop.
Save angelovstanton/d999032642e1404c1128e39f24f6e109 to your computer and use it in GitHub Desktop.
[Test]
public void ScrollFocusToControl_InCloud_ShouldFail()
{
_driver.Navigate().GoToUrl(@"https://automatetheplanet.com/compelling-sunday-14022016/");
var link = _driver.FindElement(By.PartialLinkText("Previous post"));
var jsToBeExecuted = $"window.scroll(0, {link.Location.Y});";
((IJavaScriptExecutor)_driver).ExecuteScript(jsToBeExecuted);
link.Click();
Assert.AreEqual("10 Advanced WebDriver Tips and Tricks - Part 1", _driver.Title);
}
[Test]
public void ScrollFocusToControl_InCloud_ShouldPass()
{
_driver.Navigate().GoToUrl(@"https://automatetheplanet.com/multiple-files-page-objects-item-templates/");
var link = _driver.FindElement(By.PartialLinkText("TFS Test API"));
var jsToBeExecuted = $"window.scroll(0, {link.Location.Y});";
((IJavaScriptExecutor)_driver).ExecuteScript(jsToBeExecuted);
var wait = new WebDriverWait(_driver, TimeSpan.FromMinutes(1));
var clickableElement = wait.Until(ExpectedConditions.ElementToBeClickable(By.PartialLinkText("TFS Test API")));
clickableElement.Click();
Assert.AreEqual("TFS Test API Archives - Automate The Planet", _driver.Title);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment