RelationDigest

Friday, 28 April 2023

[New post] How to handle dropdowns in Robot Framework 

Site logo image vibssingh posted: " HOME In this tutorial, we will automate the execution of DropDown in Robot Framework. Prerequisite: Install Python Install PIP Install Robot Framework Install Robot framework Selenium Library Install&" QA Automation Expert

How to handle dropdowns in Robot Framework 

vibssingh

Apr 28

HOME

In this tutorial, we will automate the execution of DropDown in Robot Framework.

Prerequisite:

  1. Install Python
  2. Install PIP
  3. Install Robot Framework
  4. Install Robot framework Selenium Library
  5. Install PyCharm IDE

Please refer to this tutorial to install Robot Framework – How to install and setup Robot Framework for Python.

Implementation Steps:

Step 1.1 - Open PyCharm and create a new project. Go to File and select New Project from the main menu.

Step 1.2 - Choose the project location. Click the "Browse" button next to the Location field and specify the directory for your project.

Deselect the Create a main.py welcome script checkbox because you will create a new Python file for this tutorial.

Click on the "Create" Button.

Step 1.3 - A new dialog appears asking to open the project using any one of the given options. I have selected New Window as I like to have separate windows for each project.

Below is the image of the new project created in PyCharms.

How to create a test to automate the options of dropdown in Robot Framework?

Step 4 - Create a new directory in the new project

Right-Click on the project, select New->Directory and provide name as Tests

Below is the image of the new directory.

Right-click on the new directory and select New File and provide the name as DropDown_Demo.robot as shown below:

Step 5 - Download ChromeBinaries from the below location

The tests are going to use the Chrome browser, so we need to download the ChromeBinaries to open a blank browser in Chrome.

https://chromedriver.chromium.org/

The chromedriver and geckodriver are placed in a folder name drivers in the RobotFramework_Demo project. I have renamed chromedriver to Chrome and geckodriver to Firefox.

Step 6 - Automate the selection of options for DropDown

We are now going to write test cases. The test case details will be as follows −

  • Open the browser and copy URL − https://demo.automationtesting.in/Register.html in Chrome
  • Select the dropdown options APIs by value
  • Select the dropdown options Microsoft Excel by index
  • Select the dropdown options CSS by label

To work with the Radio Button, we need a locator. A locator is an identifier for the textbox like id, name, class, xpath, css selector, etc.

To know more about locators, refer to these Selenium Tutorials:

 Locators in Selenium – Locate by ID, ClassName,  Name, TagName,  LinkText, PartialLinkText

Dynamic XPath  in Selenium WebDriver

CSS Selector in Selenium WebDriver

The below page shows that we have multiple DropDown options.

Let us inspect the locator of DropDown.

Below is an example of selecting the options in DropDown.

 *** Settings *** Documentation    To validate the selection of DropDown Library     SeleniumLibrary Test Teardown    Close Browser  *** Test Cases *** Select options in DropDown     Open the Browser with URL     Select the dropdown options APIs by value     Select the dropdown options Microsoft Excel by index     Select the dropdown options CSS by label  *** Keywords *** Open the Browser with URL     Create Webdriver    Chrome  executable_path=/Vibha_Personal/RobotFramework/drivers/chromedriver_linux64     Go To    https://demo.automationtesting.in/Register.html     Maximize Browser Window     Set Selenium Implicit Wait    2  Select the dropdown options APIs by value     Select From List By Value       id:Skills   APIs   Select the dropdown options Microsoft Excel by index     Select From List By Index        id:Skills   43  Select the dropdown options CSS by label     Select From List By Label       id:Skills   CSS   

All the below-mentioned keywords are derived from SeleniumLibrary except the last one. The functionality of keywords mentioned above:

1. Create Webdriver − The keyword creates an instance of Selenium WebDriver.

2. Go To - This keyword navigates the current browser window to the provided URL - https://demo.automationtesting.in/Register.html.

3. Maximize Browser Window - This keyword maximizes the current browser window.

4. Set Selenium Implicit Wait - This keyword sets the implicit wait value used by Selenium.

5. Select From List By Value − This keyword is used to select APIs option from dropdown on the current page by value.

6. Select From List By Index - This keyword is used to select Microsoft Excel option from dropdown on the current page by index.

7. Select From List By Label - This keyword is used to select CSS option from the dropdown on the current page by label.

These keywords are present in SeleniumLibrary. To know more about these keywords, please refer to this document - https://robotframework.org/SeleniumLibrary/SeleniumLibrary.htm.

To run this script, go to the command line and go to directory tests.

Step 7 - Execute the tests

We need the below command to run the Robot Framework script.

 robot DropDown_Demo.robot 

The output of the above program is

Step 5 - View Report and Log

We have the test case passed. The Robot Framework generates log.html, output.xml, and report.html by default.

Let us now see the report and log details.

Report

Right-click on report.html. Select Open In->Browser->Chrome(any browser of your wish).

The Report generated by the framework is shown below:

Log

Robot Framework has multiple log levels that control what is shown in the automatically generated log file. The default Robot Framework log level is INFO.

Right-click on log.html. Select Open In->Browser->Chrome(any browser of your wish).

That's it! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Comment
Like
Tip icon image You can also reply to this email to leave a comment.

Unsubscribe to no longer receive posts from QA Automation Expert.
Change your email settings at manage subscriptions.

Trouble clicking? Copy and paste this URL into your browser:
http://qaautomation.expert/2023/04/28/how-to-handle-dropdowns-in-robot-framework/

WordPress.com and Jetpack Logos

Get the Jetpack app to use Reader anywhere, anytime

Follow your favorite sites, save posts to read later, and get real-time notifications for likes and comments.

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com on Twitter WordPress.com on Facebook WordPress.com on Instagram WordPress.com on YouTube
WordPress.com Logo and Wordmark title=

Learn how to build your website with our video tutorials on YouTube.


Automattic, Inc. - 60 29th St. #343, San Francisco, CA 94110  

at April 28, 2023
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Making Sense of the Voices in Your Head

With Internal Family Systems ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ...

  • Sunnycare Aged Care Week 10
    https://advanceinstitute.com.au/2024/04/24/sunnycare-aged-care-week-10/?page_id=...
  • [New post] weather
    barbaraturneywielandpoetess posted: " life on a rooftop can be short ; depends whether one looks down or up . ...
  • [New post] Its Time
    ...

Search This Blog

  • Home

About Me

RelationDigest
View my complete profile

Report Abuse

Blog Archive

  • October 2025 (39)
  • September 2025 (53)
  • August 2025 (54)
  • July 2025 (59)
  • June 2025 (53)
  • May 2025 (47)
  • April 2025 (42)
  • March 2025 (30)
  • February 2025 (27)
  • January 2025 (30)
  • December 2024 (37)
  • November 2024 (31)
  • October 2024 (29)
  • September 2024 (28)
  • August 2024 (2729)
  • July 2024 (3249)
  • June 2024 (3152)
  • May 2024 (3259)
  • April 2024 (3151)
  • March 2024 (3258)
  • February 2024 (3046)
  • January 2024 (3258)
  • December 2023 (3270)
  • November 2023 (3183)
  • October 2023 (3243)
  • September 2023 (3151)
  • August 2023 (3241)
  • July 2023 (3237)
  • June 2023 (3135)
  • May 2023 (3212)
  • April 2023 (3093)
  • March 2023 (3187)
  • February 2023 (2865)
  • January 2023 (3209)
  • December 2022 (3229)
  • November 2022 (3079)
  • October 2022 (3086)
  • September 2022 (2791)
  • August 2022 (2964)
  • July 2022 (3157)
  • June 2022 (2925)
  • May 2022 (2893)
  • April 2022 (3049)
  • March 2022 (2919)
  • February 2022 (2104)
  • January 2022 (2284)
  • December 2021 (2481)
  • November 2021 (3146)
  • October 2021 (1048)
Powered by Blogger.