Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

A Deep Dive into the W3C WebDriver Specification

1,051 views

Published on

Selenium Conf Tokyo 2019

Published in: Software

A Deep Dive into the W3C WebDriver Specification

  1. 1. Peter Thomas | Distinguished Engineer | Intuit @ptrthomas
  2. 2. 2 About Me
  3. 3. 3 Agenda What is WebDriver ? Architecture Examples and Demos
  4. 4. 4 Scope of this talk Selenium Language Bindings Selenium IDE Selenium Grid Selenium the “brand” Also known as “Selenium WebDriver” the W3C WebDriver Specification use uses uses we will focus here in this talk
  5. 5. 5 a W3C Specification https://www.w3.org/TR/webdriver/ WebDriver is … “WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.” REST API e.g. Web Browsers JSON over HTTP e.g. Selenium … or even Mobile / Desktop Apps
  6. 6. 6 Simon Mavi Stewart @shs96c W3C WebDriver Specification - Editors David Burns @AutomatedTester Browser Testing and Tools Working Group https://www.w3.org/testing/browser/
  7. 7. 7 WebDriver in your stack Browser DriverBindings JSON over HTTP WebDriver REST API Framework FireFoxgeckodriverSelenium (Java)JUnit ChromechromedriverSelenium (Ruby)WatirRSpec WebdriverIO or Nightwatch.jsMocha Emulates User Controls Browser Exposes REST API Manages Sessions Language Specific WebDriver SDK Driver client Higher Level API Test Assertions Run / Reports Config / Tags etc. Selenium (Python) Selenium Base Pytest Implemented By Browser Vendors
  8. 8. 8 History : Selenium  WebDriver  W3C Selenium 2 Released 2011 W3C Specification Work 2018 W3C Recommendation Selenium & WebDriver Merge Selenium Core Browser Selenium RC WebDriver Se IDE 2008-9 (Selenium Grid not shown for simplicity) https://twitter.com/shs96c/status/1060117993898807301 Feb 2008 Selenium Core Browser Selenium RC Se IDE 2004 Jason Huggins Paul Hammant Selenium Created 2016 Selenium 3 Released Browser WebDriver (drivers) JSON Wire Protocol Selenium (bindings) WebDriver (W3C drivers) Browser Selenium IDE (new) Selenium (bindings) W3C Protocol 2006-7 Simon Stewart WebDriver WebDriver Created Browser
  9. 9. 9 Method URI Template Command POST /session New Session DELETE /session/{session id} Delete Session GET /status Status GET /session/{session id}/timeouts Get Timeouts POST /session/{session id}/timeouts Set Timeouts POST /session/{session id}/url Navigate To GET /session/{session id}/url Get Current URL POST /session/{session id}/back Back POST /session/{session id}/forward Forward POST /session/{session id}/refresh Refresh GET /session/{session id}/title Get Title GET /session/{session id}/window Get Window Handle DELETE /session/{session id}/window Close Window POST /session/{session id}/window Switch To Window GET /session/{session id}/window/handles Get Window Handles POST /session/{session id}/window/new New Window POST /session/{session id}/frame Switch To Frame POST /session/{session id}/frame/parent Switch To Parent Frame GET /session/{session id}/window/rect Get Window Rect POST /session/{session id}/window/rect Set Window Rect POST /session/{session id}/window/maximize Maximize Window POST /session/{session id}/window/minimize Minimize Window POST /session/{session id}/window/fullscreen Fullscreen Window GET /session/{session id}/element/active Get Active Element POST /session/{session id}/element Find Element POST /session/{session id}/elements Find Elements Method URI Template Command POST /session/{session id}/element/{element id}/element Find Element From Element POST /session/{session id}/element/{element id}/elements Find Elements From Element GET /session/{session id}/element/{element id}/selected Is Element Selected GET /session/{session id}/element/{element id}/attribute/{name} Get Element Attribute GET /session/{session id}/element/{element id}/property/{name} Get Element Property GET /session/{session id}/element/{element id}/css/{property name} Get Element CSS Value GET /session/{session id}/element/{element id}/text Get Element Text GET /session/{session id}/element/{element id}/name Get Element Tag Name GET /session/{session id}/element/{element id}/rect Get Element Rect GET /session/{session id}/element/{element id}/enabled Is Element Enabled POST /session/{session id}/element/{element id}/click Element Click POST /session/{session id}/element/{element id}/clear Element Clear POST /session/{session id}/element/{element id}/value Element Send Keys GET /session/{session id}/source Get Page Source POST /session/{session id}/execute/sync Execute Script POST /session/{session id}/execute/async Execute Async Script GET /session/{session id}/cookie Get All Cookies GET /session/{session id}/cookie/{name} Get Named Cookie POST /session/{session id}/cookie Add Cookie DELETE /session/{session id}/cookie/{name} Delete Cookie DELETE /session/{session id}/cookie Delete All Cookies POST /session/{session id}/actions Perform Actions DELETE /session/{session id}/actions Release Actions POST /session/{session id}/alert/dismiss Dismiss Alert POST /session/{session id}/alert/accept Accept Alert GET /session/{session id}/alert/text Get Alert Text POST /session/{session id}/alert/text Send Alert Text GET /session/{session id}/screenshot Take Screenshot GET /session/{session id}/element/{element id}/screenshot Take Element Screenshot WebDriver Commands Session Management Navigation Title Window Frame Window Size Get / Find Element(s) Find Element(s) from Element Element State Element Actions Page Source Execute Script Cookies Keyboard / Mouse / Touch Alert / Dialog Screenshot
  10. 10. 10 curl -d '{"desiredCapabilities":{"browserName":"Chrome"}}' -X POST http://localhost:9515/session curl -d '{"url":"https://github.com/login"}' -X POST http://localhost:9515/session/{session id}/url curl -d '{"using":"css selector","value":"#login_field"}' -X POST http://localhost:9515/session/{session id}/element curl -d '{"value":["hello"]}' -X POST http://localhost:9515/session/{session id}/element/{element id}/value Demo: Browser Remote Control with cURL First, start chromedriver, default port: 9515
  11. 11. 11 https://github.com/intuit/karate • API Testing • API Mocking • API Perf-Testing Example Framework - Karate https://tinyurl.com/karatejp Takanori Suzuki Open Source Test Automation Framework @KarateDS L
  12. 12. 12 https://tinyurl.com/karatedriver W3C WebDriver support in Karate (Alpha) BrowserDriverBindings JSON over HTTP WebDriver REST API Framework Chromechromedriver Windows AppWinAppDriverREST HTTP Client W3C WebDriver Adapter Karate Script (Gherkin) Karate Core (Java) Since Dec 2018 From Microsoft
  13. 13. Demo
  14. 14. 14 Drivers Target Driver Chrome chromedriver https://sites.google.com/a/chromium.org/chromedriver/home FireFox geckodriver https://github.com/mozilla/geckodriver Safari safaridriver (Mac) https://webkit.org/blog/6900/webdriver-support-in-safari-10/ MS Edge MicrosoftWebDriver (Win 10) https://docs.microsoft.com/en-us/microsoft-edge/webdriver (Windows Apps) WinAppDriver (Win 10) https://github.com/Microsoft/WinAppDriver Internet Explorer IEDriverServer (Win) https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver Only driver maintained by the Selenium team (planned end of support: Jul 19) Jim Evans | @jimevansmusic also known for the Selenium + WebDriver compliance tests http://webdriver-herald.herokuapp.com
  15. 15. 15 Spec Compliance is hard work …
  16. 16. 16 A Word about Microsoft Edge The MS Edge browser will be based on Chromium in the future Will it support WebDriver ?
  17. 17. 17 WebDriver Bindings and Frameworks Binding Language Link Selenium Java https://seleniumhq.github.io/selenium/docs/api/java/index.html Selenium Python https://seleniumhq.github.io/selenium/docs/api/py/index.html Selenium Ruby https://seleniumhq.github.io/selenium/docs/api/rb/index.html Selenium .NET https://seleniumhq.github.io/selenium/docs/api/dotnet/ Selenium JavaScript https://seleniumhq.github.io/selenium/docs/api/javascript/index.html WebdriverIO JavaScript https://webdriver.io Nightwatch.js JavaScript http://nightwatchjs.org Karate (Alpha) Java https://github.com/intuit/karate/tree/master/karate-core Framework Language Uses Link Selenide Java Selenium Java https://selenide.org SeleniumBase Python Selenium Python https://seleniumbase.com Watir Ruby Selenium Ruby http://watir.com Protractor JavaScript Selenium JavaScript https://www.protractortest.org (not an exhaustive list)
  18. 18. 18 Stable User-Facing API-s / W3C Only Selenium Grid / Docker / Cloud Tracing / Observability Site / Documentation Friendly Locators Selenium IDE The Future – Expected in Selenium 4
  19. 19. Q & A @ptrthomas Thank You !
  20. 20. 21 References (1 of 2) WebDriver GitHub: https://github.com/w3c/webdriver Selenium WebDriver (New Documentation): https://seleniumhq.github.io/docs/wd.html The Architecture of Open Source Applications: Selenium WebDriver - https://www.aosabook.org/en/selenium.html Selenium 1 / Remote Control (RC): https://www.seleniumhq.org/docs/05_selenium_rc.jsp Selenium History: https://www.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-history Selenium History: https://www.seleniumhq.org/about/history.jsp GTAC 2007: Huggins & Stewart - Selenium-RC Vs WebDriver: https://www.youtube.com/watch?v=Vlz-WmcrBL8 Happy 10th Birthday, Selenium (by Paul Hammant): https://www.thoughtworks.com/insights/blog/happy-10th-birthday-selenium The Faces Behind Selenium: https://smartbear.com/blog/test-and-monitor/the-faces-behind-selenium/ Selenium User Meetup 2008 at Google (lightning talks, venue of photo on slide #7): https://youtu.be/EDb8yOM3Vpw Summary of the above event (Matt Raible’s blog): https://raibledesigns.com/rd/entry/last_night_s_selenium_users Selenium Contributors (old site): https://www.seleniumhq.org/about/contributors.jsp WebDriver W3C Draft Announcement: https://www.w3.org/News/2012.html#entry-9496
  21. 21. 22 References (2 of 2) Selenium 2 Announcement: https://seleniumhq.wordpress.com/2011/07/08/selenium-2-0/ Selenium 2 to 3 changes: https://saucelabs.com/blog/move-over-selenium-2-why-its-time-to-upgrade-to-selenium-3 Selenium 3 Announcement: https://seleniumhq.wordpress.com/2016/10/13/selenium-3-0-out-now/ Selenium 4 changes: https://www.datio.com/qa/selenium-4-is-coming/ Selenium State of the Union (Se Conf Chicago 18): https://youtu.be/Qlt5YUGmN1Y Selenium 4 Project Board (GitHub): https://github.com/SeleniumHQ/selenium/projects/2 Sauce Labs Selenium 4 FAQ: https://saucelabs.com/blog/frequently-asked-questions-about-selenium-4 Selenium and WebDriverIO: https://medium.com/@specktackle/selenium-and-webdriverio-a-historical-overview-6f8fbf94b418 Evaluating Cypress and TestCafe: https://medium.com/yld-engineering-blog/evaluating-cypress-and-testcafe-for-end-to-end-testing-fcd0303d2103 Comparison of E2E Testing Tools: https://blog.scottlogic.com/2018/01/08/pros-cons-e2e-testing-tools.html Selenium Atoms: https://firefox-source-docs.mozilla.org/testing/marionette/marionette/SeleniumAtoms.html Watir History: http://watir.com/history/

×