Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web UI Automation with Selenium for Beginners

Og Maciel
November 15, 2017

Web UI Automation with Selenium for Beginners

In this talk I will cover web ui automation using selenium with a focus on the Python programming language. Attendants will learn how to easily gather web ui information, record their actions and play them back via Selenium IDE, then learn how to write Python code to perform the same actions and finally how to use your automation with py.test. Other topic that will be discussed, time allowing, will be how to use SauceLabs to execute automated tests on multiple types of operating systems and web browser combinations.

Og Maciel

November 15, 2017
Tweet

More Decks by Og Maciel

Other Decks in Programming

Transcript

  1. • Name: Og Maciel • Work: Red Hat since 2011;

    rPath previously • Job: Senior Manager, Quality Engineering • Quality Engineer since 2008 • Projects: ◦ RH Satellite 5 and 6 ◦ Pulp ◦ Sonar
  2. Objective aka What’s in this for you? • Cover Web

    UI automation using Selenium with a focus on the Python programming language • Learn how to easily gather Web UI information, record their actions and play them back via Selenium IDE or Scirocco • Write Python code to perform the same actions • Run your code with unitest and py.test • Time allowing, use SauceLabs to execute automated tests on multiple types of operating systems and web browser combinations. • BONUS: Travis.CI
  3. When I say web UI Automation... … I mean: •

    Control a web browser by accessing a web page’s elements • Programmatically :) • Web elements are part of the DOM object
  4. Locating web elements • Different schemes for locating web elements

    ◦ CSS attributes ◦ Value ◦ Tag name ◦ XPATH ◦ ...
  5. Selenium • Selenium seems to dominate this area • Selenium

    webdriver let’s you interact with elements ◦ Click ◦ Select ◦ Type ◦ Mouse interaction (hover, move, etc) ◦ ...
  6. Overview • Firefox plugin ONLY • Can be tricky to

    install • Requires Firefox == 45 or older :/ • Records all interactions with browser • Can replay all recordings • Allows for multiple tests to be recorded • GREAT IDE with tons of useful features • Exports test cases into Python code (and other formats) • Requires creativity to ensure that playing back activities will wait for web elements to be present
  7. Overview • Easier to install • Works with latest Chrome

    browser • Records all interactions with browser • Can replay all recordings • Not as full fledged IDE as Selenium IDE • Limited range of commands • Limited options for exporting test cases (Python is NOT supported)
  8. Overview Install the selenium python module mkvirtualenv -p $(which python3)

    -i selenium selenium-talk pip install bpython Install Web Driver ◦ Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloads ◦ Edge: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ ◦ Firefox: https://github.com/mozilla/geckodriver/releases ◦ Safari: https://webkit.org/blog/6900/webdriver-support-in-safari-10/ For this presentation I chose to use the web driver for the chrome web browser. * include the ChromeDriver location in your PATH environment variable
  9. Links • Git Repository: https://github.com/omaciel/Web-UI-Automation-with-Selenium-for-Beginners • Older Firefox downloads: https://ftp.mozilla.org/pub/firefox/releases/

    • Selenium IDE: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/ • Scirocco: https://chrome.google.com/webstore/detail/scirocco-recorder-for-chr/ibclajljffeaafooicpmkcjdnkbao iih • Selenium: http://docs.seleniumhq.org/ • Python Selenium: http://selenium-python.readthedocs.io/ • Pytest: http://pytest.org/ • SauceLabs: • Travis: https://travis-ci.org/ • Videos: ◦ Selenium IDE: https://youtu.be/e1jrrg39V_k ◦ Scirocco: https://youtu.be/zEL6-pt9hoM ◦ Interactive Python + Selenium: https://youtu.be/FQwwiVh5Cok ◦ Using SauceLabs: https://youtu.be/dxr8lxTv90A