際際滷

際際滷Share a Scribd company logo
Selenium Overview
What does that one guy do?
Started @ Google
JavaScript injection
Remote Control (RC)
Merged with the WebDriver Project (current)
Performs native browser events
Mainly developed by Google and Mozilla
Selenium Short HistorySelenium History
Forget it. Period.
Heard about Selenium IDE?
History Lesson Over!
Document Object Model - DOM
API Access to browser events via JSON
How does it work?
Magic!
English?
Full access to browser
Native Events
Navigates the DOM
CSS Locators
XPath Queries
Why is Selenium Good?
Free
Support
Drivers
Grid
Languages
Drivers Grid
English ´ Do You Speak It?
Hub and Nodes
More Machines =
More Tests
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
Simple Sample of Selenium
Yay for Alliteration!
CRTL + C
ALT + Tab
CTRL + V
Maintainable tests == false
Issues with the Sample
Simplifies Test Creation
Defines elements that are on a page
Maintainable++;
Page Object Model/Pattern
public class LoginPage {
[FindsBy(How = How.Id, Using = "username")]
private IWebElement txtUserName;
[FindsBy(How = How.Id, Using = "password")]
private IWebElement txtPassword;
[FindsBy(How = How.Id, Using = "logon")]
private IWebElement btnLogOn;
public bool LogOn(string userName, string password) {
txtUserName.SendKeys(userName);
txtPassword.SendKeys(password);
btnLogOn.Click();
}
}
Page Object Model Sample
[TestFixture]
public class LoginTest
{
public static IWebDriver driver;
[SetUp]
public void Setup() {
driver = new FirefoxDriver()
}
[TearDown]
public void TearDown() {
driver.Quit();
}
[Test]
public static void TestUserLogin(IWebDriver driver) {
driver.Navigate().GoToURL(^http://gmail.com ̄);
LoginPage Login = new LoginPage();
PageFactory.InitElements(driver, Login);
Login.LoginOn("testuser", "password");
HomePage Home = new HomePage();
PageFactory.InitElements(driver, Home);
}
}
Assert.True(Maintainable + 1 == Max)
Assert Failed!
Code in ^English ̄
Method Chaining
Login Method -> Dashboard Page
Dashboard Page -> Pub Approval Queue
Fluent Testing
[Test]
public void LoginTest()
{
var page = HomePage.LoginAs(^admin ̄, ^password ̄).menu.LogOut();
Assert.True(page.Text.Contains(), ^Thank you! ̄)
}
^English ̄ Example
[TestCaseSource(typeof(BaseTest), "AllTestCases")]
public void ApproveCompanyTest(Browsers b, Platforms p,Resolutions r, int v)
{
var page = new HomePage(this.driver).
gotoLogin().
LoginAs("admin", "password").
GoToPublisherApprovalQueue().
ApproveCompany("gizmodo");
Assert.That(page.SearchFor("gizmodo").GetNumberOfRecords().Equals(0));
}
Actual Example
Applitool Eyes
Automated Visual Testing
Browser Mob Proxy
Network Simulation
Fiddler
Groupon Grid
Easier Management of the Grid
Selenium Extensions
Fighting Layout Bugs
Find layout issues
Ex. Text touching the edge of a
border
aShot
Screen Grab of specified Elements
!C#
Boolean end = True;
Now everyone can have sprinkles!
Questions?

More Related Content

Selenium

  • 1. Selenium Overview What does that one guy do?
  • 2. Started @ Google JavaScript injection Remote Control (RC) Merged with the WebDriver Project (current) Performs native browser events Mainly developed by Google and Mozilla Selenium Short HistorySelenium History
  • 3. Forget it. Period. Heard about Selenium IDE?
  • 5. Document Object Model - DOM API Access to browser events via JSON How does it work? Magic!
  • 6. English? Full access to browser Native Events Navigates the DOM CSS Locators XPath Queries
  • 7. Why is Selenium Good? Free Support Drivers Grid Languages
  • 8. Drivers Grid English ´ Do You Speak It? Hub and Nodes More Machines = More Tests
  • 9. WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com"); WebElement element = driver.findElement(By.name("q")); element.sendKeys("Cheese!"); element.submit(); System.out.println("Page title is: " + driver.getTitle()); Simple Sample of Selenium Yay for Alliteration!
  • 10. CRTL + C ALT + Tab CTRL + V Maintainable tests == false Issues with the Sample
  • 11. Simplifies Test Creation Defines elements that are on a page Maintainable++; Page Object Model/Pattern
  • 12. public class LoginPage { [FindsBy(How = How.Id, Using = "username")] private IWebElement txtUserName; [FindsBy(How = How.Id, Using = "password")] private IWebElement txtPassword; [FindsBy(How = How.Id, Using = "logon")] private IWebElement btnLogOn; public bool LogOn(string userName, string password) { txtUserName.SendKeys(userName); txtPassword.SendKeys(password); btnLogOn.Click(); } } Page Object Model Sample [TestFixture] public class LoginTest { public static IWebDriver driver; [SetUp] public void Setup() { driver = new FirefoxDriver() } [TearDown] public void TearDown() { driver.Quit(); } [Test] public static void TestUserLogin(IWebDriver driver) { driver.Navigate().GoToURL(^http://gmail.com ̄); LoginPage Login = new LoginPage(); PageFactory.InitElements(driver, Login); Login.LoginOn("testuser", "password"); HomePage Home = new HomePage(); PageFactory.InitElements(driver, Home); } }
  • 13. Assert.True(Maintainable + 1 == Max) Assert Failed!
  • 14. Code in ^English ̄ Method Chaining Login Method -> Dashboard Page Dashboard Page -> Pub Approval Queue Fluent Testing
  • 15. [Test] public void LoginTest() { var page = HomePage.LoginAs(^admin ̄, ^password ̄).menu.LogOut(); Assert.True(page.Text.Contains(), ^Thank you! ̄) } ^English ̄ Example
  • 16. [TestCaseSource(typeof(BaseTest), "AllTestCases")] public void ApproveCompanyTest(Browsers b, Platforms p,Resolutions r, int v) { var page = new HomePage(this.driver). gotoLogin(). LoginAs("admin", "password"). GoToPublisherApprovalQueue(). ApproveCompany("gizmodo"); Assert.That(page.SearchFor("gizmodo").GetNumberOfRecords().Equals(0)); } Actual Example
  • 17. Applitool Eyes Automated Visual Testing Browser Mob Proxy Network Simulation Fiddler Groupon Grid Easier Management of the Grid Selenium Extensions
  • 18. Fighting Layout Bugs Find layout issues Ex. Text touching the edge of a border aShot Screen Grab of specified Elements !C#
  • 19. Boolean end = True; Now everyone can have sprinkles!

Editor's Notes

  • #4: Some of you may have it is a browser extension to firefox allows click and record test creation
  • #5: Congrats
  • #7: Back refresh Manage tabs, window size and cookies
  • #9: firefox is not explicit on this as firefox is built into the core project standard fire fox install