SlideShare a Scribd company logo
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
IWebDriver driver = new ChromeDriver();
IWebDriver driver = new ChromeDriver();
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
IWebDriver driver = new ChromeDriver();
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
// Search for a phrase
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
IWebDriver driver = new ChromeDriver();
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
// Search for a phrase
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
// Verify results appear
driver.Title.ToLower().Should().Contain("panda");
driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0);
IWebDriver driver = new ChromeDriver();
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
// Search for a phrase
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
// Verify results appear
driver.Title.ToLower().Should().Contain("panda");
driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0);
driver.Quit();
IWebDriver driver = new ChromeDriver();
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
// Search for a phrase
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
// Verify results appear
driver.Title.ToLower().Should().Contain("panda");
driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0);
driver.Quit();
IWebDriver driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
// Search for a phrase
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
// Verify results appear
driver.Title.ToLower().Should().Contain("panda");
driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0);
driver.Quit();
IWebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
// Search for a phrase
wait.Until(d => d.FindElements(By.Id("search_form_input_homepage")).Count > 0);
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
// Verify results appear
wait.Until(d => d.Title.ToLower().Contains("panda"));
wait.Until(d => d.FindElements(By.CssSelector("a.result__a"))).Count > 0);
driver.Quit();
IWebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
// Open the search engine
driver.Navigate().GoToUrl("https://duckduckgo.com/");
// Search for a phrase
wait.Until(d => d.FindElements(By.Id("search_form_input_homepage")).Count > 0);
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
// Verify results appear
wait.Until(d => d.Title.ToLower().Contains("panda"));
wait.Until(d => d.FindElements(By.CssSelector("a.result__a"))).Count > 0);
driver.Quit();
IWebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
driver.Navigate().GoToUrl("https://duckduckgo.com/");
wait.Until(d => d.FindElements(By.Id("search_form_input_homepage")).Count > 0);
driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda");
driver.FindElement(By.Id("search_button_homepage")).Click();
wait.Until(d => d.Title.ToLower().Contains("panda"));
wait.Until(d => d.FindElements(By.CssSelector("a.result__a"))).Count > 0);
driver.Quit();
public class SearchPage
{
}
public class SearchPage
{
public const string Url = "https://duckduckgo.com/";
public static By SearchInput => By.Id("search_form_input_homepage");
public static By SearchButton => By.Id("search_button_homepage");
}
public class SearchPage
{
public const string Url = "https://duckduckgo.com/";
public static By SearchInput => By.Id("search_form_input_homepage");
public static By SearchButton => By.Id("search_button_homepage");
public IWebDriver Driver { get; private set; }
public SearchPage(IWebDriver driver) => Driver = driver;
}
public class SearchPage
{
public const string Url = "https://duckduckgo.com/";
public static By SearchInput => By.Id("search_form_input_homepage");
public static By SearchButton => By.Id("search_button_homepage");
public IWebDriver Driver { get; private set; }
public SearchPage(IWebDriver driver) => Driver = driver;
public void Load() => driver.Navigate().GoToUrl(Url);
}
public class SearchPage
{
public const string Url = "https://duckduckgo.com/";
public static By SearchInput => By.Id("search_form_input_homepage");
public static By SearchButton => By.Id("search_button_homepage");
public IWebDriver Driver { get; private set; }
public SearchPage(IWebDriver driver) => Driver = driver;
public void Load() => driver.Navigate().GoToUrl(Url);
public void Search(string phrase)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.Until(d => d.FindElements(SearchInput).Count > 0);
driver.FindElement(SearchInput).SendKeys(phrase);
driver.FindElement(SearchButton).Click();
}
}
IWebDriver driver = new ChromeDriver();
SearchPage searchPage = new SearchPage(driver);
searchPage.Load();
searchPage.Search(“panda”);
IWebDriver driver = new ChromeDriver();
SearchPage searchPage = new SearchPage(driver);
searchPage.Load();
searchPage.Search(“panda”);
ResultPage resultPage = new ResultPage(driver);
resultPage.WaitForTitle(“panda”);
resultPage.WaitForResultLinks();
driver.Quit();
public class AnyPage
{
// ...
}
public class AnyPage
{
// ...
public void ClickButton()
{
Wait.Until(d => d.FindElements(Button).Count > 0);
driver.FindElement(Button).Click();
}
}
public class AnyPage
{
// ...
public void ClickButton()
{
Wait.Until(d => d.FindElements(Button).Count > 0);
driver.FindElement(Button).Click();
}
public void ClickOtherButton()
{
Wait.Until(d => d.FindElements(OtherButton).Count > 0);
driver.FindElement(OtherButton).Click();
}
}
public class AnyPage
{
// ...
public void ClickButton()
{
Wait.Until(d => d.FindElements(Button).Count > 0);
driver.FindElement(Button).Click();
}
public void ClickOtherButton()
{
Wait.Until(d => d.FindElements(OtherButton).Count > 0);
driver.FindElement(OtherButton).Click();
}
}
public class BasePage
{
}
public class BasePage
{
public IWebDriver Driver { get; private set; }
public WebDriverWait Wait { get; private set; }
public SearchPage(IWebDriver driver)
{
Driver = driver;
Wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));
}
}
public class BasePage
{
public IWebDriver Driver { get; private set; }
public WebDriverWait Wait { get; private set; }
public SearchPage(IWebDriver driver)
{
Driver = driver;
Wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));
}
protected void Click(By locator)
{
Wait.Until(d => d.FindElements(locator).Count > 0);
driver.FindElement(locator).Click();
}
}
public class AnyPage : BasePage
{
// ...
public AnyPage(IWebDriver driver) : base(driver) {}
public void ClickButton() => Click(Button);
public void ClickOtherButton() => Click(OtherButton);
}
public class AnyPage : BasePage
{
// ...
public void ClickButton() => Click(Button);
public void ClickOtherButton() => Click(OtherButton);
public void ButtonText() => Text(Button);
public void OtherButtonText() => Text(OtherButton);
public void IsButtonDisplayed() => IsDisplayed(Button);
public void IsButtonDisplayed() => IsDisplayed(OtherButton);
}
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
•
•
•
•
•
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
// NuGet Packages:
// Boa.Constrictor
// FluentAssertions
// Selenium.Support
// Selenium.WebDriver
using Boa.Constrictor.Logging;
using Boa.Constrictor.Screenplay;
using Boa.Constrictor.WebDriver;
using FluentAssertions;
using OpenQA.Selenium.Chrome;
using static Boa.Constrictor.WebDriver.WebLocator;
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
public class BrowseTheWeb : IAbility
{
public IWebDriver WebDriver { get; }
private BrowseTheWeb(IWebDriver driver) =>
WebDriver = driver;
  public static BrowseTheWeb With(IWebDriver driver) =>
new BrowseTheWeb(driver);
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
public static class SearchPage
{
public const string Url =
"https://www.duckduckgo.com/";
  public static IWebLocator SearchInput => L(
"DuckDuckGo Search Input",
By.Id("search_form_input_homepage"));
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
public void AttemptsTo(ITask task)
{
task.PerformAs(this);
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
public class Navigate : ITask
{
private string Url { get; set; }
  private Navigate(string url) => Url = url;
  public static Navigate ToUrl(string url) => new Navigate(url);
  public void PerformAs(IActor actor)
{
var driver = actor.Using<BrowseTheWeb>().WebDriver;
driver.Navigate().GoToUrl(Url);
}
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
public class Navigate : ITask
{
private string Url { get; set; }
  private Navigate(string url) => Url = url;
  public static Navigate ToUrl(string url) => new Navigate(url);
  public void PerformAs(IActor actor)
{
var driver = actor.Using<BrowseTheWeb>().WebDriver;
driver.Navigate().GoToUrl(Url);
}
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
public static class SearchPage
{
public const string Url =
"https://www.duckduckgo.com/";
  public static IWebLocator SearchInput => L(
"DuckDuckGo Search Input",
By.Id("search_form_input_homepage"));
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
public TAnswer AskingFor<TAnswer>(IQuestion<TAnswer> question)
{
return question.RequestAs(this);
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
public class ValueAttribute : IQuestion<string>
{
public IWebLocator Locator { get; }
  private ValueAttribute(IWebLocator locator) => Locator = locator;
  public static ValueAttribute Of(IWebLocator locator) => new ValueAttribute(locator);
  public string RequestAs(IActor actor)
{
var driver = actor.Using<BrowseTheWeb>().WebDriver;
actor.AttemptsTo(Wait.Until(Existence.Of(Locator), IsEqualTo.True()));
return driver.FindElement(Locator.Query).GetAttribute("value");
}
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
public class ValueAttribute : IQuestion<string>
{
public IWebLocator Locator { get; }
  private ValueAttribute(IWebLocator locator) => Locator = locator;
  public static ValueAttribute Of(IWebLocator locator) => new ValueAttribute(locator);
  public string RequestAs(IActor actor)
{
var driver = actor.Using<BrowseTheWeb>().WebDriver;
actor.AttemptsTo(Wait.Until(Existence.Of(Locator), IsEqualTo.True()));
return driver.FindElement(Locator.Query).GetAttribute("value");
}
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
public static class SearchPage
{
public const string Url =
"https://www.duckduckgo.com/";
  public static IWebLocator SearchInput => L(
"DuckDuckGo Search Input",
By.Id("search_form_input_homepage"));
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
public class SearchDuckDuckGo : ITask
{
public string Phrase { get; }
  private SearchDuckDuckGo(string phrase) =>
Phrase = phrase;
  public static SearchDuckDuckGo For(string phrase) =>
new SearchDuckDuckGo(phrase);
  public void PerformAs(IActor actor)
{
actor.AttemptsTo(SendKeys.To(SearchPage.SearchInput, Phrase));
actor.AttemptsTo(Click.On(SearchPage.SearchButton));
}
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
public class SearchDuckDuckGo : ITask
{
public string Phrase { get; }
  private SearchDuckDuckGo(string phrase) =>
Phrase = phrase;
  public static SearchDuckDuckGo For(string phrase) =>
new SearchDuckDuckGo(phrase);
  public void PerformAs(IActor actor)
{
actor.AttemptsTo(SendKeys.To(SearchPage.SearchInput, Phrase));
actor.AttemptsTo(Click.On(SearchPage.SearchButton));
}
}
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
public static IWebLocator ResultLinks => L(
"DuckDuckGo Result Page Links",
By.ClassName("result__a"));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
actor.AttemptsTo(QuitWebDriver.ForBrowser());
IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
actor.Can(BrowseTheWeb.With(new ChromeDriver()));
actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
actor.AttemptsTo(QuitWebDriver.ForBrowser());
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
•
•
•
•
•
•
•
•
•
•
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight
Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight

More Related Content

PDF
Better Selenium Tests with Geb - Selenium Conf 2014
PDF
The report of JavaOne2011 about groovy
KEY
Paris js extensions
PPTX
KEY
Deploying
PDF
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
KEY
Authentication
PDF
History of jQuery
Better Selenium Tests with Geb - Selenium Conf 2014
The report of JavaOne2011 about groovy
Paris js extensions
Deploying
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
Authentication
History of jQuery

What's hot (20)

PPTX
Dev Jumpstart: Build Your First App with MongoDB
KEY
Google
PDF
Write Less Do More
PDF
Non stop random2b
PDF
Hidden Treasures in Project Wonder
KEY
Html5 For Jjugccc2009fall
PPTX
Introduction to the new official C# Driver developed by 10gen
PDF
jQuery Essentials
PDF
jQuery in 15 minutes
PDF
The love child of Android and .NET: App development with Xamarin
KEY
Welcome the Offical C# Driver for MongoDB
PDF
Введение в REST API
PDF
Mongo db for c# developers
PDF
JSON and Swift, Still A Better Love Story Than Twilight
PDF
jQuery Essentials
PDF
HTML5 APIs - Where no man has gone before! - Altran
PDF
async/await in Swift
PPTX
Windows Azure Storage & Sql Azure
PPT
KEY
Sprout core and performance
Dev Jumpstart: Build Your First App with MongoDB
Google
Write Less Do More
Non stop random2b
Hidden Treasures in Project Wonder
Html5 For Jjugccc2009fall
Introduction to the new official C# Driver developed by 10gen
jQuery Essentials
jQuery in 15 minutes
The love child of Android and .NET: App development with Xamarin
Welcome the Offical C# Driver for MongoDB
Введение в REST API
Mongo db for c# developers
JSON and Swift, Still A Better Love Story Than Twilight
jQuery Essentials
HTML5 APIs - Where no man has gone before! - Altran
async/await in Swift
Windows Azure Storage & Sql Azure
Sprout core and performance
Ad

Similar to Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight (20)

PPTX
The Screenplay Pattern: Better Interactions for Better Automation
PDF
Browser-level testing
PPTX
Web Automation Testing Using Selenium
PPTX
Selenium withnet
PPTX
Web driver training
PDF
Advanced Techniques to Build an Efficient Selenium Framework
PDF
Rf meetup 16.3.2017 tampere share
PPTX
Writing Well Abstracted Automation on Foundations of Jello
PDF
Gilt Groupe's Selenium 2 Conversion Challenges
PPTX
Introduction to Selenium Web Driver
PPTX
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
PPTX
Marcin Wasilczyk - Page objects with selenium
PPTX
Web testing with Selenium
PPTX
How To Automate Cross Browser Testing
PPT
Automation with Selenium Presented by Quontra Solutions
PPTX
Get Started With Selenium 3 and Selenium 3 Grid
PPTX
Selenium WebDriver
PDF
Boston selenium meetup: Selenium 2
PDF
Prevent Test Automation Shelfware: A Selenium-WebDriver Case Study
PPTX
Webdriver with Thucydides - TdT@Cluj #18
The Screenplay Pattern: Better Interactions for Better Automation
Browser-level testing
Web Automation Testing Using Selenium
Selenium withnet
Web driver training
Advanced Techniques to Build an Efficient Selenium Framework
Rf meetup 16.3.2017 tampere share
Writing Well Abstracted Automation on Foundations of Jello
Gilt Groupe's Selenium 2 Conversion Challenges
Introduction to Selenium Web Driver
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Marcin Wasilczyk - Page objects with selenium
Web testing with Selenium
How To Automate Cross Browser Testing
Automation with Selenium Presented by Quontra Solutions
Get Started With Selenium 3 and Selenium 3 Grid
Selenium WebDriver
Boston selenium meetup: Selenium 2
Prevent Test Automation Shelfware: A Selenium-WebDriver Case Study
Webdriver with Thucydides - TdT@Cluj #18
Ad

More from Agile Testing Alliance (20)

PPTX
#Interactive Session by Anindita Rath and Mahathee Dandibhotla, "From Good to...
PDF
#Interactive Session by Ajay Balamurugadas, "Where Are The Real Testers In T...
PPTX
#Interactive Session by Jishnu Nambiar and Mayur Ovhal, "Monitoring Web Per...
PDF
#Interactive Session by Pradipta Biswas and Sucheta Saurabh Chitale, "Navigat...
PDF
#Interactive Session by Apoorva Ram, "The Art of Storytelling for Testers" at...
PPTX
#Interactive Session by Nikhil Jain, "Catch All Mail With Graph" at #ATAGTR2023.
PPTX
#Interactive Session by Ashok Kumar S, "Test Data the key to robust test cove...
PPTX
#Interactive Session by Seema Kohli, "Test Leadership in the Era of Artificia...
PDF
#Interactive Session by Ashwini Lalit, RRR of Test Automation Maintenance" at...
PPTX
#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...
PPTX
#Interactive Session by Kirti Ranjan Satapathy and Nandini K, "Elements of Qu...
PPTX
#Interactive Session by Sudhir Upadhyay and Ashish Kumar, "Strengthening Test...
PPTX
#Interactive Session by Sayan Deb Kundu, "Testing Gen AI Applications" at #AT...
PDF
#Interactive Session by Dinesh Boravke, "Zero Defects – Myth or Reality" at #...
PPTX
#Interactive Session by Saby Saurabh Bhardwaj, "Redefine Quality Assurance –...
PDF
#Keynote Session by Sanjay Kumar, "Innovation Inspired Testing!!" at #ATAGTR2...
PDF
#Keynote Session by Schalk Cronje, "Don’t Containerize me" at #ATAGTR2023.
PPTX
#Interactive Session by Chidambaram Vetrivel and Venkatesh Belde, "Revolution...
PDF
#Interactive Session by Aniket Diwakar Kadukar and Padimiti Vaidik Eswar Dat...
PPTX
#Interactive Session by Vivek Patle and Jahnavi Umarji, "Empowering Functiona...
#Interactive Session by Anindita Rath and Mahathee Dandibhotla, "From Good to...
#Interactive Session by Ajay Balamurugadas, "Where Are The Real Testers In T...
#Interactive Session by Jishnu Nambiar and Mayur Ovhal, "Monitoring Web Per...
#Interactive Session by Pradipta Biswas and Sucheta Saurabh Chitale, "Navigat...
#Interactive Session by Apoorva Ram, "The Art of Storytelling for Testers" at...
#Interactive Session by Nikhil Jain, "Catch All Mail With Graph" at #ATAGTR2023.
#Interactive Session by Ashok Kumar S, "Test Data the key to robust test cove...
#Interactive Session by Seema Kohli, "Test Leadership in the Era of Artificia...
#Interactive Session by Ashwini Lalit, RRR of Test Automation Maintenance" at...
#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...
#Interactive Session by Kirti Ranjan Satapathy and Nandini K, "Elements of Qu...
#Interactive Session by Sudhir Upadhyay and Ashish Kumar, "Strengthening Test...
#Interactive Session by Sayan Deb Kundu, "Testing Gen AI Applications" at #AT...
#Interactive Session by Dinesh Boravke, "Zero Defects – Myth or Reality" at #...
#Interactive Session by Saby Saurabh Bhardwaj, "Redefine Quality Assurance –...
#Keynote Session by Sanjay Kumar, "Innovation Inspired Testing!!" at #ATAGTR2...
#Keynote Session by Schalk Cronje, "Don’t Containerize me" at #ATAGTR2023.
#Interactive Session by Chidambaram Vetrivel and Venkatesh Belde, "Revolution...
#Interactive Session by Aniket Diwakar Kadukar and Padimiti Vaidik Eswar Dat...
#Interactive Session by Vivek Patle and Jahnavi Umarji, "Empowering Functiona...

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
A Presentation on Artificial Intelligence
Diabetes mellitus diagnosis method based random forest with bat algorithm
Programs and apps: productivity, graphics, security and other tools
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
NewMind AI Weekly Chronicles - August'25-Week II
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
A comparative analysis of optical character recognition models for extracting...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Electronic commerce courselecture one. Pdf
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
A Presentation on Artificial Intelligence

Session on "The Screenplay Pattern: Better Interactions for Better Automation" By Andrew Knight

  • 14. IWebDriver driver = new ChromeDriver();
  • 15. IWebDriver driver = new ChromeDriver(); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/");
  • 16. IWebDriver driver = new ChromeDriver(); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/"); // Search for a phrase driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click();
  • 17. IWebDriver driver = new ChromeDriver(); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/"); // Search for a phrase driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click(); // Verify results appear driver.Title.ToLower().Should().Contain("panda"); driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0);
  • 18. IWebDriver driver = new ChromeDriver(); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/"); // Search for a phrase driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click(); // Verify results appear driver.Title.ToLower().Should().Contain("panda"); driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0); driver.Quit();
  • 19. IWebDriver driver = new ChromeDriver(); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/"); // Search for a phrase driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click(); // Verify results appear driver.Title.ToLower().Should().Contain("panda"); driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0); driver.Quit();
  • 20. IWebDriver driver = new ChromeDriver(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/"); // Search for a phrase driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click(); // Verify results appear driver.Title.ToLower().Should().Contain("panda"); driver.FindElements(By.CssSelector("a.result__a")).Should().BeGreaterThan(0); driver.Quit();
  • 21. IWebDriver driver = new ChromeDriver(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/"); // Search for a phrase wait.Until(d => d.FindElements(By.Id("search_form_input_homepage")).Count > 0); driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click(); // Verify results appear wait.Until(d => d.Title.ToLower().Contains("panda")); wait.Until(d => d.FindElements(By.CssSelector("a.result__a"))).Count > 0); driver.Quit();
  • 22. IWebDriver driver = new ChromeDriver(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); // Open the search engine driver.Navigate().GoToUrl("https://duckduckgo.com/"); // Search for a phrase wait.Until(d => d.FindElements(By.Id("search_form_input_homepage")).Count > 0); driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click(); // Verify results appear wait.Until(d => d.Title.ToLower().Contains("panda")); wait.Until(d => d.FindElements(By.CssSelector("a.result__a"))).Count > 0); driver.Quit();
  • 23. IWebDriver driver = new ChromeDriver(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); driver.Navigate().GoToUrl("https://duckduckgo.com/"); wait.Until(d => d.FindElements(By.Id("search_form_input_homepage")).Count > 0); driver.FindElement(By.Id("search_form_input_homepage")).SendKeys("panda"); driver.FindElement(By.Id("search_button_homepage")).Click(); wait.Until(d => d.Title.ToLower().Contains("panda")); wait.Until(d => d.FindElements(By.CssSelector("a.result__a"))).Count > 0); driver.Quit();
  • 25. public class SearchPage { public const string Url = "https://duckduckgo.com/"; public static By SearchInput => By.Id("search_form_input_homepage"); public static By SearchButton => By.Id("search_button_homepage"); }
  • 26. public class SearchPage { public const string Url = "https://duckduckgo.com/"; public static By SearchInput => By.Id("search_form_input_homepage"); public static By SearchButton => By.Id("search_button_homepage"); public IWebDriver Driver { get; private set; } public SearchPage(IWebDriver driver) => Driver = driver; }
  • 27. public class SearchPage { public const string Url = "https://duckduckgo.com/"; public static By SearchInput => By.Id("search_form_input_homepage"); public static By SearchButton => By.Id("search_button_homepage"); public IWebDriver Driver { get; private set; } public SearchPage(IWebDriver driver) => Driver = driver; public void Load() => driver.Navigate().GoToUrl(Url); }
  • 28. public class SearchPage { public const string Url = "https://duckduckgo.com/"; public static By SearchInput => By.Id("search_form_input_homepage"); public static By SearchButton => By.Id("search_button_homepage"); public IWebDriver Driver { get; private set; } public SearchPage(IWebDriver driver) => Driver = driver; public void Load() => driver.Navigate().GoToUrl(Url); public void Search(string phrase) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); wait.Until(d => d.FindElements(SearchInput).Count > 0); driver.FindElement(SearchInput).SendKeys(phrase); driver.FindElement(SearchButton).Click(); } }
  • 29. IWebDriver driver = new ChromeDriver(); SearchPage searchPage = new SearchPage(driver); searchPage.Load(); searchPage.Search(“panda”);
  • 30. IWebDriver driver = new ChromeDriver(); SearchPage searchPage = new SearchPage(driver); searchPage.Load(); searchPage.Search(“panda”); ResultPage resultPage = new ResultPage(driver); resultPage.WaitForTitle(“panda”); resultPage.WaitForResultLinks(); driver.Quit();
  • 32. public class AnyPage { // ... public void ClickButton() { Wait.Until(d => d.FindElements(Button).Count > 0); driver.FindElement(Button).Click(); } }
  • 33. public class AnyPage { // ... public void ClickButton() { Wait.Until(d => d.FindElements(Button).Count > 0); driver.FindElement(Button).Click(); } public void ClickOtherButton() { Wait.Until(d => d.FindElements(OtherButton).Count > 0); driver.FindElement(OtherButton).Click(); } }
  • 34. public class AnyPage { // ... public void ClickButton() { Wait.Until(d => d.FindElements(Button).Count > 0); driver.FindElement(Button).Click(); } public void ClickOtherButton() { Wait.Until(d => d.FindElements(OtherButton).Count > 0); driver.FindElement(OtherButton).Click(); } }
  • 36. public class BasePage { public IWebDriver Driver { get; private set; } public WebDriverWait Wait { get; private set; } public SearchPage(IWebDriver driver) { Driver = driver; Wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30)); } }
  • 37. public class BasePage { public IWebDriver Driver { get; private set; } public WebDriverWait Wait { get; private set; } public SearchPage(IWebDriver driver) { Driver = driver; Wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30)); } protected void Click(By locator) { Wait.Until(d => d.FindElements(locator).Count > 0); driver.FindElement(locator).Click(); } }
  • 38. public class AnyPage : BasePage { // ... public AnyPage(IWebDriver driver) : base(driver) {} public void ClickButton() => Click(Button); public void ClickOtherButton() => Click(OtherButton); }
  • 39. public class AnyPage : BasePage { // ... public void ClickButton() => Click(Button); public void ClickOtherButton() => Click(OtherButton); public void ButtonText() => Text(Button); public void OtherButtonText() => Text(OtherButton); public void IsButtonDisplayed() => IsDisplayed(Button); public void IsButtonDisplayed() => IsDisplayed(OtherButton); }
  • 52. // NuGet Packages: // Boa.Constrictor // FluentAssertions // Selenium.Support // Selenium.WebDriver using Boa.Constrictor.Logging; using Boa.Constrictor.Screenplay; using Boa.Constrictor.WebDriver; using FluentAssertions; using OpenQA.Selenium.Chrome; using static Boa.Constrictor.WebDriver.WebLocator;
  • 53. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger());
  • 54. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver()));
  • 55. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); public class BrowseTheWeb : IAbility { public IWebDriver WebDriver { get; } private BrowseTheWeb(IWebDriver driver) => WebDriver = driver;   public static BrowseTheWeb With(IWebDriver driver) => new BrowseTheWeb(driver); }
  • 56. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); public static class SearchPage { public const string Url = "https://www.duckduckgo.com/";   public static IWebLocator SearchInput => L( "DuckDuckGo Search Input", By.Id("search_form_input_homepage")); }
  • 57. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url));
  • 58. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); public void AttemptsTo(ITask task) { task.PerformAs(this); }
  • 59. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); public class Navigate : ITask { private string Url { get; set; }   private Navigate(string url) => Url = url;   public static Navigate ToUrl(string url) => new Navigate(url);   public void PerformAs(IActor actor) { var driver = actor.Using<BrowseTheWeb>().WebDriver; driver.Navigate().GoToUrl(Url); } }
  • 60. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); public class Navigate : ITask { private string Url { get; set; }   private Navigate(string url) => Url = url;   public static Navigate ToUrl(string url) => new Navigate(url);   public void PerformAs(IActor actor) { var driver = actor.Using<BrowseTheWeb>().WebDriver; driver.Navigate().GoToUrl(Url); } }
  • 61. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); public static class SearchPage { public const string Url = "https://www.duckduckgo.com/";   public static IWebLocator SearchInput => L( "DuckDuckGo Search Input", By.Id("search_form_input_homepage")); }
  • 62. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
  • 63. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); public TAnswer AskingFor<TAnswer>(IQuestion<TAnswer> question) { return question.RequestAs(this); }
  • 64. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); public class ValueAttribute : IQuestion<string> { public IWebLocator Locator { get; }   private ValueAttribute(IWebLocator locator) => Locator = locator;   public static ValueAttribute Of(IWebLocator locator) => new ValueAttribute(locator);   public string RequestAs(IActor actor) { var driver = actor.Using<BrowseTheWeb>().WebDriver; actor.AttemptsTo(Wait.Until(Existence.Of(Locator), IsEqualTo.True())); return driver.FindElement(Locator.Query).GetAttribute("value"); } }
  • 65. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); public class ValueAttribute : IQuestion<string> { public IWebLocator Locator { get; }   private ValueAttribute(IWebLocator locator) => Locator = locator;   public static ValueAttribute Of(IWebLocator locator) => new ValueAttribute(locator);   public string RequestAs(IActor actor) { var driver = actor.Using<BrowseTheWeb>().WebDriver; actor.AttemptsTo(Wait.Until(Existence.Of(Locator), IsEqualTo.True())); return driver.FindElement(Locator.Query).GetAttribute("value"); } }
  • 66. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); public static class SearchPage { public const string Url = "https://www.duckduckgo.com/";   public static IWebLocator SearchInput => L( "DuckDuckGo Search Input", By.Id("search_form_input_homepage")); }
  • 67. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty();
  • 68. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
  • 69. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); public class SearchDuckDuckGo : ITask { public string Phrase { get; }   private SearchDuckDuckGo(string phrase) => Phrase = phrase;   public static SearchDuckDuckGo For(string phrase) => new SearchDuckDuckGo(phrase);   public void PerformAs(IActor actor) { actor.AttemptsTo(SendKeys.To(SearchPage.SearchInput, Phrase)); actor.AttemptsTo(Click.On(SearchPage.SearchButton)); } }
  • 70. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); public class SearchDuckDuckGo : ITask { public string Phrase { get; }   private SearchDuckDuckGo(string phrase) => Phrase = phrase;   public static SearchDuckDuckGo For(string phrase) => new SearchDuckDuckGo(phrase);   public void PerformAs(IActor actor) { actor.AttemptsTo(SendKeys.To(SearchPage.SearchInput, Phrase)); actor.AttemptsTo(Click.On(SearchPage.SearchButton)); } }
  • 71. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda"));
  • 72. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
  • 73. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
  • 74. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True())); public static IWebLocator ResultLinks => L( "DuckDuckGo Result Page Links", By.ClassName("result__a"));
  • 75. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
  • 76. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
  • 77. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True())); actor.AttemptsTo(QuitWebDriver.ForBrowser());
  • 78. IActor actor = new Actor(name: "Andy", logger: new ConsoleLogger()); actor.Can(BrowseTheWeb.With(new ChromeDriver())); actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); actor.AskingFor(ValueAttribute.Of(SearchPage.SearchInput)).Should().BeEmpty(); actor.AttemptsTo(SearchDuckDuckGo.For("panda")); actor.AttemptsTo(Wait.Until(Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True())); actor.AttemptsTo(QuitWebDriver.ForBrowser());
  • 95.