Selenium 2 User Interactions API
Upcoming SlideShare
Loading in...5
×
 

Selenium 2 User Interactions API

on

  • 6,730 views

 

Statistics

Views

Total Views
6,730
Views on SlideShare
4,528
Embed Views
2,202

Actions

Likes
1
Downloads
34
Comments
0

3 Embeds 2,202

http://seleniumexamples.com 2185
http://www.slideshare.net 14
http://webcache.googleusercontent.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Selenium 2 User Interactions API Selenium 2 User Interactions API Presentation Transcript

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