Building a Driver: Lessons Learned From Developing the Internet Explorer Driver

1,662 views

Published on

Published in: Technology
  • Be the first to comment

Building a Driver: Lessons Learned From Developing the Internet Explorer Driver

  1. 1. Building a Driver:Lessons Learned from Developingthe Internet Explorer DriverJim EvansLead Member of Technical Staff /jimevansmusic @jimevansmusic in/jimevansmusic
  2. 2. Or:Jim EvansLead Member of Technical Staff /jimevansmusic @jimevansmusic in/jimevansmusic
  3. 3. How I Learned to Stop Worrying andLove Internet ExplorerJim EvansLead Member of Technical Staff /jimevansmusic @jimevansmusic in/jimevansmusic
  4. 4. Who Am I?
  5. 5. A Little History (and some housekeeping)http://zyrus86.deviantart.com/art/Evolution-of-the-Geek-95267948
  6. 6. Lesson 1: Be Language-Independent(for browser-independent things)
  7. 7. Lesson 1a: Distribute a Standalone Executable(if you decided to use native code) •Written in native code •Examples: •chromedriver.exe •IEDriverServer.exe
  8. 8. Lesson 2: Implement the JSON Wire Protocol (because RemoteWebDriver is your friend)http://www.flickr.com/photos/srhbth/487911150/sizes/o/in/faves-
  9. 9. Lesson 2: Implement the JSON Wire Protocol(because RemoteWebDriver is your friend)
  10. 10. Lesson 2: Implement the JSON Wire Protocol(because RemoteWebDriver is your friend) public class InternetExplorerDriver : RemoteWebDriver { private static int serverPort = 5555; private InternetExplorerDriverServer server; public InternetExplorerDriver() : base(new HttpCommandExecutor(new Uri("http://localhost:" + serverPort.ToString()), ( TimeSpan.FromSeconds(60)), new InternetExplorerOptions().ToCapabilities()) { } protected override void StartClient() { if (this.server == null) { this.server = new InternetExplorerDriverServer(); } if (this.server != null) { if (!InternetExplorerDriverServer.IsRunning) { this.server.Start(serverPort); } } } protected override void StopClient() { if (this.server != null) { this.server.Dispose(); } } }
  11. 11. Lesson 3: Use Automation Atoms (but use them with care)http://vepca.files.wordpress.com/2011/10/gen-dynamics-tower.jpg
  12. 12. Lesson 3: Use Automation Atoms(but use them with care) Consider the following HTML element: <input id=“my_button type=“button” onclick=“alert(‘hello, world’)” /> W h a t h a p p e n s if W e b E le m e n t . c lic k ( ) is u s in g a J a v a S c r ip t o n ly im p le m e n t a t io n ?
  13. 13. Lesson 3: Use Automation Atoms(but use them with care) Consider the following HTML element: <form name=“my_form” action=“” onsubmit=“alert(‘hello, world’)” method=“post” /> W h a t h a p p e n s if W e b E le m e n t . s u b m it ( ) is u s in g a J a v a S c r ip t o n ly im p le m e n t a t io n ?
  14. 14. Lesson 4: Use Native Events(for interacting with elements)
  15. 15. Lesson 4: Use Native Events(for interacting with elements)
  16. 16. Lesson 4: Use Native Events(for interacting with elements) Element with hovering menu Actions actions = new Actions(driver); actions .MoveToElement(element) .Perform(); Menu flashes and disappears
  17. 17. Lesson 5: Log Everything (to preserve your sanity)http://cariferraro.com/wp-content/uploads/2012/02/MedievalScribe_JeanMielot.jpg
  18. 18. Resources Initial email thread on Selenium Developers mailing list discussing IE driver rewrite: https://groups.google.com/d/topic/selenium-developers/TdYzD5e9IxI/discussion Follow-up email thread on Selenium Developers mailing list discussing status of IE driver rewrite: https://groups.google.com/d/topic/selenium-developers/oPmn0dBt4zU/discussion JSON Wire Protocol specification: http://code.google.com/p/selenium/wiki/JsonWireProtocol Automation Atoms description: http://code.google.com/p/selenium/wiki/AutomationAtoms

×