building a driver: lessons learned from developing the internet explorer driver

19
Building a Driver: Lessons Learned from Developing the Internet Explorer Driver Jim Evans Lead Member of Technical Staff /jimevansmusic @jimevansmusic in/jimevansmusic

Upload: seleniumconf

Post on 04-Jul-2015

1.254 views

Category:

Technology


1 download

TRANSCRIPT

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

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

Jim EvansLead Member of Technical Staff

/jimevansmusic

@jimevansmusic

in/jimevansmusic

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

Or:

Jim EvansLead Member of Technical Staff

/jimevansmusic

@jimevansmusic

in/jimevansmusic

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

How I Learned to Stop Worrying and Love Internet Explorer

Jim EvansLead Member of Technical Staff

/jimevansmusic

@jimevansmusic

in/jimevansmusic

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

Who Am I?

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

A Little History

http://zyrus86.deviantart.com/art/Evolution-of-the-Geek-95267948

(and some housekeeping)

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

Lesson 1: Be Language-Independent(for browser-independent things)

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

Lesson 1a: Distribute a Standalone Executable(if you decided to use native code)

•Written in native code•Examples:

•chromedriver.exe•IEDriverServer.exe

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

Lesson 2: Implement the JSON Wire Protocol

http://www.flickr.com/photos/srhbth/487911150/sizes/o/in/faves-broccoli/

(because RemoteWebDriver is your friend)

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

Lesson 2: Implement the JSON Wire Protocol(because RemoteWebDriver is your friend)

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

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)

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

Lesson 3: Use Automation Atoms

http://vepca.files.wordpress.com/2011/10/gen-dynamics-tower.jpg

(but use them with care)

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

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)

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

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)

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

Lesson 4: Use Native Events(for interacting with elements)

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

Lesson 4: Use Native Events(for interacting with elements)

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

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

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

Lesson 5: Log Everything(to preserve your sanity)

http://cariferraro.com/wp-content/uploads/2012/02/MedievalScribe_JeanMielot.jpg

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

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

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