Handling ListBoxes in selenium

ListBox is an element where user can select/deselect one or more items from it.

To identify the ListBox on webpage, look for select tag and attribute should be ‘multiple’ to select multiple items and there will be option tag which contains each item in it.[as shown below]

How can we identify a ListBox on webpage:

Now let’s get all the options from the ListBox

allvals is having list of all the ListBox items in it.

Let’s see some of the operations with ListBox

OutPut:

Content posted is based on learning or working experience, please leave comments if anything needs to be added or updated, discuss your queries on our facebook:qavalidation.com, Thanks!

Leave a Reply

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

%d bloggers like this: