User Interactions API Eran (eran.mes@gmail.com)‏
Existing API <ul><li>     </li></ul><ul><li>     WebElement.click(); </li></ul><ul><li>     WebElement.sendKeys(CharSequen...
This API is limiting
New User Interactions API <ul><li>Requirements: </li></ul><ul><ul><li>Finer grained control over actions (i.e. Holding dow...
Input device emulation <ul><li>interface Keyboard { </li></ul><ul><li>   void sendKeys(WebElement to, CharSequence...  </l...
Actions <ul><li>public class KeyDownAction implements Action { </li></ul><ul><li>   public KeyDownAction(Keyboard keyboard...
Actions - continued <ul><li>public class PressAndHoldMouseAction implements Action { </li></ul><ul><li>   public PressAndH...
Complex actions <ul><li>class ComplexAction implements Action { </li></ul><ul><li>   ... </li></ul><ul><li>} </li></ul><ul...
Summary <ul><ul><li>The existing API for interacting with elements is basic but mostly sufficient. </li></ul></ul><ul><ul>...
Upcoming SlideShare
Loading in …5
×

Selenium 2 User Interactions API

6,205 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,205
On SlideShare
0
From Embeds
0
Number of Embeds
2,410
Actions
Shares
0
Downloads
38
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Selenium 2 User Interactions API

  1. 1. User Interactions API Eran (eran.mes@gmail.com)‏
  2. 2. Existing API <ul><li>     </li></ul><ul><li>     WebElement.click(); </li></ul><ul><li>    WebElement.sendKeys(CharSequence... keys); </li></ul><ul><li>  </li></ul><ul><li>And if you insist... </li></ul><ul><li>  </li></ul><ul><li>    WebElement.submit(); </li></ul><ul><li>     WebElement.clear(); </li></ul><ul><li>    RenderedWebElement.dragAndDropOn(...); </li></ul><ul><li>    RenderedWebElement.dragAndDropBy(...); </li></ul><ul><li>  </li></ul>
  3. 3. This API is limiting
  4. 4. New User Interactions API <ul><li>Requirements: </li></ul><ul><ul><li>Finer grained control over actions (i.e. Holding down the shift key). </li></ul></ul><ul><ul><li>Support more actions (Double-click, right-click). </li></ul></ul><ul><ul><li>Describe gestures that are available only on mobile browsers (Swipe, pinch to zoom)‏ </li></ul></ul><ul><ul><li>Allow combination of all of the above into sequences of actions. </li></ul></ul><ul><li>  </li></ul><ul><li>This API should supplement, not replace, the existing API. </li></ul>
  5. 5. Input device emulation <ul><li>interface Keyboard { </li></ul><ul><li>  void sendKeys(WebElement to, CharSequence...  </li></ul><ul><li>     keysToSend); </li></ul><ul><li>  void pressKey(WebElement to, Keys keyToPress);   void releaseKey(WebElement to, Keys        </li></ul><ul><li>    keyToRelease); } </li></ul><ul><li>interface Mouse { </li></ul><ul><li>  void click(WebElement onElement); </li></ul><ul><li>  void mouseDown(WebElement onElement); </li></ul><ul><li>  void mouseUp(WebElement onElement); </li></ul><ul><li>  void doubleClick(WebElement onElement); </li></ul><ul><li>  void mouseMove(WebElement from, WebElement to); </li></ul><ul><li>  ... </li></ul><ul><li>} </li></ul>
  6. 6. Actions <ul><li>public class KeyDownAction implements Action { </li></ul><ul><li>  public KeyDownAction(Keyboard keyboard, </li></ul><ul><li>    WebElement toElement, Keys key) {     ...   }   public void perform() {     keyboard.pressKey(toElement, key);   } } </li></ul>
  7. 7. Actions - continued <ul><li>public class PressAndHoldMouseAction implements Action { </li></ul><ul><li>  public PressAndHoldMouseAction(Mouse mouse, </li></ul><ul><li>    WebElement onElement ) {     ...   }   public void perform() {     mouse.mouseDown(onElement);   } } </li></ul>
  8. 8. Complex actions <ul><li>class ComplexAction implements Action { </li></ul><ul><li>  ... </li></ul><ul><li>} </li></ul><ul><li>ComplexAction sequence = new ComplexAction(); </li></ul><ul><li>sequence.add(new KeyDownAction(...)); </li></ul><ul><li>sequence.add(new MouseDownAction(...)); </li></ul><ul><li>sequence.add(new MouseMoveAction(...)); </li></ul><ul><li>sequence.add(new MouseUpAction(...)); </li></ul><ul><li>sequence.add(new KeyUpAction(...)); </li></ul><ul><li>sequence.perform(); </li></ul>
  9. 9. Summary <ul><ul><li>The existing API for interacting with elements is basic but mostly sufficient. </li></ul></ul><ul><ul><li>The new Interactions API was born out of necessity to emulate complex user scenarios. </li></ul></ul><ul><ul><li>The Interactions API will supplement, not replace, the existing API (APIs can be mixed). </li></ul></ul><ul><ul><li>Implementation is per-browser - will start with HtmlUnit and IE, progress to Firefox. </li></ul></ul><ul><li>  </li></ul><ul><li>Code: </li></ul><ul><li>     http://code.google.com/p/selenium/source/browse/branches </li></ul><ul><li>     /interactions_api </li></ul>

×