building a driver: lessons learned from developing the internet explorer driver
TRANSCRIPT
Building a Driver:Lessons Learned from Developing the Internet Explorer Driver
Jim EvansLead Member of Technical Staff
/jimevansmusic
@jimevansmusic
in/jimevansmusic
Or:
Jim EvansLead Member of Technical Staff
/jimevansmusic
@jimevansmusic
in/jimevansmusic
How I Learned to Stop Worrying and Love Internet Explorer
Jim EvansLead Member of Technical Staff
/jimevansmusic
@jimevansmusic
in/jimevansmusic
Who Am I?
A Little History
http://zyrus86.deviantart.com/art/Evolution-of-the-Geek-95267948
(and some housekeeping)
Lesson 1: Be Language-Independent(for browser-independent things)
Lesson 1a: Distribute a Standalone Executable(if you decided to use native code)
•Written in native code•Examples:
•chromedriver.exe•IEDriverServer.exe
Lesson 2: Implement the JSON Wire Protocol
http://www.flickr.com/photos/srhbth/487911150/sizes/o/in/faves-broccoli/
(because RemoteWebDriver is your friend)
Lesson 2: Implement the JSON Wire Protocol(because RemoteWebDriver is your friend)
Lesson 2: Implement the JSON Wire Protocol
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(); } }}
(because RemoteWebDriver is your friend)
Lesson 3: Use Automation Atoms
http://vepca.files.wordpress.com/2011/10/gen-dynamics-tower.jpg
(but use them with care)
Lesson 3: Use Automation Atoms
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 i f W e b E le m e n t . c l i c k ( ) i s 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 ?
(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 i f W e b E le m e n t . s u b m it ( ) i s 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 ?
Lesson 3: Use Automation Atoms(but use them with care)
Lesson 4: Use Native Events(for interacting with elements)
Lesson 4: Use Native Events(for interacting with elements)
Lesson 4: Use Native Events(for interacting with elements)
Actions actions = new Actions(driver);actions .MoveToElement(element) .Perform();
Element with hovering menu
Menu flashes and disappears
Lesson 5: Log Everything(to preserve your sanity)
http://cariferraro.com/wp-content/uploads/2012/02/MedievalScribe_JeanMielot.jpg
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