Web Automation using Selenium
Autor: Ana Sârbescu
Software Testing Community
in Macedonia
November 2015
Summary:
● Why QA automation?
● All kind of tools for automation!
● Automation Framework?
● Using Selenium for web automated testing
● …with examples.
Why should we automate?
● Lack of resources and too much to test.
● Higher level of confidence, higher coverage.
● Free your time for creative testing!
● Agile approach to testing
– Regression gets little time during a Sprint
– Continuous increase in what needs to be tested
What tool we can use?
● Payed vs Freeware
– You won’t get the money
for it! ☺
– But it would be much
easier if you would.
– Free tools are not so
easy to use.
– Though they might be
more powerful.
● Recording vs Scripting
– For recording you need
no programming skills.
– But the options are very
rigid.
– With programming skills
you can make the world
go round…automatically.
Oh way…it already does..
➢ Sometimes you don’t have free tools to do what you need (ex.
Multiple platforms/Compatibility testing)
Programming Skills?
● Basic! ^_^
● Depends on the tool
● Depends on the framework type (recording or
scripting)
● Depending on your application type
● Depending on your testing goal (unit testing,
functionality testing, security testing etc)
The. FRAMEWORK. !
● What does an automation framework mean?
– Specific language
– Continuous Integration
– Available Test Data
– BDD?
● Who needs to do it? Well…who can. ☺
● Why is it needed? Because TIME!
Selenium Webdriver.
● For WEB. “Selenium automates browsers. ”
● It interrogates and manipulates the HTML.
● Contains domain-specific language (Selenese).
● Works with all browsers and platforms.
● Can be run remotely on different devices, at the
same time.
● It integrates with so many tools.
● Works with most languages: Java, C#, Groovy, Perl,
PHP, Python and Ruby
How we write tests in Selenium?
● Using its main actions:
– Initiate the browser:
● WebDriver myBrowser = new FirefoxWebdriver;
– Navigate to URL:
● Java: myBrowser.get("http://www.google.com");
● C#: myBrowser.Url = "http://www.google.com";
– Find elements:
● WebElement myElement = browser.findElement(By.id
("coolestWidgetEvah"));
● List<WebElement> myList = browser.findElements(By.
className(“differentOptions"));
– Verify condition
● Ifs, Verify and Assertions.
Finding elements by
● ID:
– By.id(“cheese”);
● Class:
– By.class(“cheese”);
● Name:
– By.name(“cheese”);
● Tag Name:
– By.tagName(“cheese”);
● LinkText/partial link text:
– By.linkText(“cheese”);
● CSS:
– By.cssSelector(“#food span.dairy.aged”);
● XPath:
– By.xpath(“//input”);
Verify commands. And Waits.
Verify vs Assertion
● verifyTitle/assertTitle
● verifyTextPresent
● verifyElementPresent
Implicit Wait:
– WebElement myItem = (new WebDriverWait(driver, 10)) .until
(ExpectedConditions.presenceOfElementLocated(By.id("myItem")));
– wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
Explicit Wait:
– driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Other useful commands
● Send Keys:
– element.sendKeys("Cheese!");
● Click Button:
– driver.findElement(By.id("submit")).click();
● Select options:
– List<WebElement> allOptions = select.findElements(By.
tagName("option"));
● Switch frames/pop-ups:
– driver.switchTo().frame("frameName");
– Alert alert = driver.switchTo().alert();
Organizing your tests
● Junit, TestNG, Testem, Telerik, Nightwatch,
NodeJS, SoapUI etc
● Test suits, test grouping, tagging
● Configuration for different platforms
Ta daaaaaa!!!
No questions, Thank you!

Web automation using selenium.ppt

  • 1.
    Web Automation usingSelenium Autor: Ana Sârbescu Software Testing Community in Macedonia November 2015
  • 2.
    Summary: ● Why QAautomation? ● All kind of tools for automation! ● Automation Framework? ● Using Selenium for web automated testing ● …with examples.
  • 3.
    Why should weautomate? ● Lack of resources and too much to test. ● Higher level of confidence, higher coverage. ● Free your time for creative testing! ● Agile approach to testing – Regression gets little time during a Sprint – Continuous increase in what needs to be tested
  • 4.
    What tool wecan use? ● Payed vs Freeware – You won’t get the money for it! ☺ – But it would be much easier if you would. – Free tools are not so easy to use. – Though they might be more powerful. ● Recording vs Scripting – For recording you need no programming skills. – But the options are very rigid. – With programming skills you can make the world go round…automatically. Oh way…it already does.. ➢ Sometimes you don’t have free tools to do what you need (ex. Multiple platforms/Compatibility testing)
  • 5.
    Programming Skills? ● Basic!^_^ ● Depends on the tool ● Depends on the framework type (recording or scripting) ● Depending on your application type ● Depending on your testing goal (unit testing, functionality testing, security testing etc)
  • 6.
    The. FRAMEWORK. ! ●What does an automation framework mean? – Specific language – Continuous Integration – Available Test Data – BDD? ● Who needs to do it? Well…who can. ☺ ● Why is it needed? Because TIME!
  • 7.
    Selenium Webdriver. ● ForWEB. “Selenium automates browsers. ” ● It interrogates and manipulates the HTML. ● Contains domain-specific language (Selenese). ● Works with all browsers and platforms. ● Can be run remotely on different devices, at the same time. ● It integrates with so many tools. ● Works with most languages: Java, C#, Groovy, Perl, PHP, Python and Ruby
  • 8.
    How we writetests in Selenium? ● Using its main actions: – Initiate the browser: ● WebDriver myBrowser = new FirefoxWebdriver; – Navigate to URL: ● Java: myBrowser.get("http://www.google.com"); ● C#: myBrowser.Url = "http://www.google.com"; – Find elements: ● WebElement myElement = browser.findElement(By.id ("coolestWidgetEvah")); ● List<WebElement> myList = browser.findElements(By. className(“differentOptions")); – Verify condition ● Ifs, Verify and Assertions.
  • 11.
    Finding elements by ●ID: – By.id(“cheese”); ● Class: – By.class(“cheese”); ● Name: – By.name(“cheese”); ● Tag Name: – By.tagName(“cheese”); ● LinkText/partial link text: – By.linkText(“cheese”); ● CSS: – By.cssSelector(“#food span.dairy.aged”); ● XPath: – By.xpath(“//input”);
  • 12.
    Verify commands. AndWaits. Verify vs Assertion ● verifyTitle/assertTitle ● verifyTextPresent ● verifyElementPresent Implicit Wait: – WebElement myItem = (new WebDriverWait(driver, 10)) .until (ExpectedConditions.presenceOfElementLocated(By.id("myItem"))); – wait.until(ExpectedConditions.elementToBeClickable(By.id("someid"))); Explicit Wait: – driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  • 13.
    Other useful commands ●Send Keys: – element.sendKeys("Cheese!"); ● Click Button: – driver.findElement(By.id("submit")).click(); ● Select options: – List<WebElement> allOptions = select.findElements(By. tagName("option")); ● Switch frames/pop-ups: – driver.switchTo().frame("frameName"); – Alert alert = driver.switchTo().alert();
  • 14.
    Organizing your tests ●Junit, TestNG, Testem, Telerik, Nightwatch, NodeJS, SoapUI etc ● Test suits, test grouping, tagging ● Configuration for different platforms
  • 15.