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

Stripping down RemoteWebDriver

Stripping down RemoteWebDriver

How does Selenium actually drive a remote browser.

Santiago Suarez Ordoñez

October 07, 2012
Tweet

More Decks by Santiago Suarez Ordoñez

Other Decks in Programming

Transcript

  1. Stripping down Remote WebDriver How does Selenium actually drive a

    remove browser http://bit.ly/stripping-down-remote-webdriver
  2. Intro Santiago Suarez Ordoñez >5 years with Selenium and test

    automation Selenium committer Sauce Ninja at Sauce Labs @santiycr [email protected]
  3. Agenda • What's Remote WebDriver • The JSON Wire Protocol

    • The Desired Capabilities object • Augmenters • Handling local files • API Docs • The codebase
  4. How is Remote WebDriver different Remote WebDriver is all drivers!!

    Pros • Separates where tests run from where the browser is • Allows tests to use browsers not available on the current OS Cons • Requires an external server • Introduces extra latency to tests
  5. Step by step 1. get the Selenium server 2. start

    your remote WebDriver server 3. choose your desired capabilities 4. point Remote WebDriver to the right location 5. run your tests remotely
  6. The JSON Wire Protocol WebDriver's communication channel • RESTful protocol

    • JSON over HTTP • Intent in the test, actions through the wire http://code.google.com/p/selenium/wiki/JsonWireProtocol
  7. API vs SPI API: Object oriented (WebDriver's style) username =

    driver.find_element_by_id("username") username.send_keys("santi") SPI: Procedural and stateless (RC's style) find_element(using="id", value="username") send_keys(element="e0", value="santi")
  8. The Desired Capabilities object • A hash sent to the

    server • Used to start the right driver • Drivers have special capabilities • Server sends capabilities back (informing what has been given) http://code.google.com/p/selenium/wiki/DesiredCapabilities
  9. How about browser profiles? Stick to the FirefoxProfile class. Remote

    base64 encodes and sends it transparently!! File file = new File("firebug-1.8.1.xpi"); FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.addExtension(file); firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); DesiredCapabilities capabilities = new DesiredCapabilities.Firefox(); capabilities.setFirefoxProfile(firefoxProfile); WebDriver driver = new RemoteWebDriver(capabilities);
  10. How about file uploads? I introduce you setFileDetector! driver.setFileDetector(newLocalFileDetector()); fileinput.sendKeys("/Users/sso/local/file");

    1. WebDriver detects a path and finds the file 2. Sends it base64 encoded and gets the remote path 3. Uses sendKeys with the new (remote) path https://gist.github.com/1508946
  11. API Documentation • Java API Docs • Ruby API Docs

    • Python API Docs • C# API Docs All linked from: http://code.google.com/p/selenium/
  12. QA?