Selenium Useful Commands

Published On: 30 May 2019.By .
  • Quality Engineering

How to handle Autocomplete text box in Selenium WebDriver

Now a days, in most of the applications, we can see a ‘Auto Complete’ text boxes which will help users to quickly find the option from a pre-populated list of values based on the text that is entered by the user. We can handle autocomplete text box by two ways- by index or by text visible.

By index

By text visible

How to select dropdown in Selenium WebDriver

In this we will see how to handle drop down in selenium webdriver. Firstly to do so we have to import package named org.openqa.selenium.support.ui.Select then we will find elements and then select element either by visible text, index or value.

Select by visible text

Select by index

Select by value

How to handle frames in Selenium WebDriver

IFrame is a web page which is embedded in another web page or an HTML document. It is basically used to insert content from other sources into the webpage. SwitchTo is used to handle frames in Selenium Webdriver.

By Index

By Id or Name

By WebElement

How to handle alerts in Selenium WebDriver

Alert is basically a small message box which is shown as notification to the user to give some kind of message to the user or to ask for any permission. It can also be used to show warnings to the user.

To click on the ‘Cancel’ button on the alert

To click on the ‘OK’ button on the alert

To capture alert message

How to tap element in Selenium WebDriver in Mobile

In order to use Tap firstly we have to import two packages import io.appium.java_client.TouchAction and import io.appium.java_client.touch.offset.PointOption. We can single tap on element or we can tap on element using coordinates.

Firstly import the following packages-

Then define variables-

Tap element using point of coordinates-

Single Tap

How to Scroll using Selenium WebDriver

Scroll bar is basically used to move around the screen if the whole content is not visible on the screen. Two types of scroll is basically used- Vertical scroll and Horizontal scroll. Vertically scroll is basically used to move the scroll bar vertically and Horizontal scroll is used to move the scroll bar horizontally.

Vertical Scroll

Horizontal Scroll

How to Scroll using Selenium WebDriver in Mobile

UI Automator is used to scroll in Mobile. It will scroll the page until users find the text upto which we want to scroll.

Related content

That’s all for this blog