Home > Automation Testing > Handling Different types of elements in protractor

Handling Different types of elements in protractor

To automate any type of web application there are two operations we need to perform. First identifying the element second performing actions on that web element. Each type of web element should be handled in different ways. This article will help to understand actions to be performed on different type of web elements. 

Click() function

We use click function to perform operations like clicking on button, clicking on links, Clicking on checkbox and radio button.

Usage of click would look like this.

sendKeys() function

sendKeys() function is used to enter the values in text box, entering file path for file upload.

Usage of sendKeys would look like this.

Handling select or dropdown:

In protractor dropdown can be handled by first identifying select box and then option inside it. Using click() function we can select option inside select or dropdown.

Below code would select option “Pune” inside the select box “CitySelection”

Handling multiple Elements:

Multiple elements can be identified using element.all() function.

Below code shows usage of element.all() function. Identify all the links from webpage and click on last link.

Javascript Executor:

If the element is not clickable, editable and not selectable then we can use javascript executer.

Syntax:

browser.driver.executeScript(“JavaScriptCode”);

Example:

Actions in Protractor:

To simulate mouse actions and keyboard keys strokes we can use actions functions.

Enter the text:

Double Click:

Mouse Move:

Right click:

 

This Article is TAGGED in . BOOKMARK THE permalink.

Avatar photo
Amit Bharamasali
Automation Software Test Engineer. Skills: Manual Testing, Selenium, Java, Protractor, JavaScript, Katalon Studio, Groovy, Appium, Sahi, Sahi Script and UI/UX testing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">