Selenium Testing - SPLessons

Selenium User Interactions

Home > Lesson > Chapter 13
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Selenium User Interactions

Selenium User Interactions

shape Description

Selenium User Interactions, HTML5 is getting the possibility to beat the world internet. Disastrously it has additionally recommended that Selenium 1 has hit a divider in with which enhancements it's going to take up with. It can't play with these new progressions like canvas. The new Selenium 2 API is endeavoring to address a few of these issues with the manner that it drives the desktop. Probably the most massive things that have left the paintings on Selenium 2 is the ability to manage segments at the page like a consumer might. This may increasingly drag issues around a web page or regardless of working with canvas applications. Utilizing the mouse, or support, at a low-measure to perform a bit tolerable matters. The superior consumer Interactions API grants us to do things like moving and moreover gives us the capacity to finish some thing like preserve down a key and pass the mouse around or carry on composing. underneath i have amassed some case underneath that you could how we can use the new advanced consumer interaction API that is a bit of the Selenium 2 API. A rapid word, this API just manages Linux and windows.

User Interactions

shape Description

Selenium User Interactions - With a specific quit goal to create a succession of actions, make use of the actions generator to construct it. initially, layout it. [java] Actions builder = new Actions(driver); builder.keyDown(Keys.CONTROL) .click(someElement) .click(someOtherElement) .keyUp(Keys.CONTROL); [/java] Selenium User Interactions - Following are the some interactions such as. Keyboard Interactions - As of these days, keyboard collaboration occurred through a specific element and Web Driver ensured the thing is in the suitable nation for this cooperation. This essentially comprised of looking over the thing into the view port and concentrating on the component. Mouse interactions - Mouse activities have a landscape - the detail outlook of the mouse. So whilst panorama a banding collectively for some wimp sports, the primary activity might be at the same time tolerate to the objective of the detail applied as relationship, the second one pastime may be in appreciate to the vicinity of the mouse as the do of the last activity. Generating Action chains - The action chain generator actualizes the Builder animal of propensity to fuse a CompositeAction containing a gathering of different sports. This should diminish building sports with the aid of designing an movements chains generator example and conjuring it's fabricate() way to cope with addition the complicated activity. [java]Actions builder = new Actions(driver); Action dragAndDrop = builder.clickAndHold(someElement) .moveToElement(otherElement) .release(otherElement) .build(); dragAndDrop.perform();[/java] Following are the keyboard interface methods.
Method Description
void sendKeys(CharSequence… keysToSend) It is expecting a parameter of a type that implements CharSequence.
void releaseKey(Keys keyToRelease) It is used to release the event action.
void pressKey(Keys keyToPress) It is activated when user press any button on keyboard.
void contextClick(WebElement onElement) It is the method to click on a particular event.
void mouseMove(WebElement toElement) IT is utilized to move mouse depend on the input of the user.
void mouseDown(WebElement onElement) It is used to drag the mouse down.
void click(WebElement onElement) It is used when the same element is clicked using the click() method of the WebElement interface, then the click is triggered.
void mouseUp(WebElement onElement) It is used to drag the mouse up.
Native events versus synthetic events - In Web Driver propelled patron connections are situation to by as a choice recreating the JavaScript occasions straightforwardly or with the aid of giving the device a reveal to explicit the JavaScript events. nearby activities illustrate the purchaser cooperation better at the same time as manufactured activities are level computerized, which boot be determining in Linux when up to the individual window supervisors are utilized. Following is the desk for supporting events on exclusive browsers.
Browser Operating System Native Events Synthetic Events
Firefox Linux Supported Supported (default)
Firefox Windows Supported(default) Supported
Internet Explorer Windows Supported(default) Not supported
ItemEvent CheckBox,CheckboxMenuItem,Choice,List ItemListener Created when list-item or checkbox is pressed.
Chrome Linux/Windows Supported* Not supported
Opera Linux/Windows Supported(default) Not supported.
HtmlUnit Linux/Windows Supported(default) Not supported.

Summary

shape Key Points

  • ?void releaseKey(Keys keyToRelease) Releases a modifier key.
  • void mouseUp(WebElement onElement) is used to release mouse button.
  • The developer can insert values into a text box using the sendkeys method.