This document discusses lessons learned from developing the Internet Explorer driver for Selenium. It covers 5 key lessons: 1) be language-independent, 2) implement the JSON wire protocol, 3) use automation atoms carefully, 4) use native events for interacting with elements, and 5) log everything to help with debugging. The document provides examples and explanations for each lesson.
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Building a Driver: Lessons Learned From Developing the Internet Explorer Driver
1. Building a Driver:
Lessons Learned from Developing
the Internet Explorer Driver
Jim Evans
Lead Member of Technical Staff
/jimevansmusic
@jimevansmusic
in/jimevansmusic
5. A Little History
(and some housekeeping)
http://zyrus86.deviantart.com/art/Evolution-of-the-Geek-95267948
6. Lesson 1: Be Language-Independent
(for browser-independent things)
7. Lesson 1a: Distribute a Standalone Executable
(if you decided to use native code)
•Written in native code
•Examples:
•chromedriver.exe
•IEDriverServer.exe
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. Lesson 2: Implement the JSON Wire Protocol
(because RemoteWebDriver is your friend)
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. Lesson 3: Use Automation Atoms
(but use them with care)
http://vepca.files.wordpress.com/2011/10/gen-dynamics-tower.jpg
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. 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. Lesson 4: Use Native Events
(for interacting with elements)
15. Lesson 4: Use Native Events
(for interacting with elements)
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. Lesson 5: Log Everything
(to preserve your sanity)
http://cariferraro.com/wp-content/uploads/2012/02/MedievalScribe_JeanMielot.jpg
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