2

Most of the solutions for this issue represenred as this

drowpdown = driver.find_element(:id, 'option1') option = Selenium::WebDriver::Select::Support.new(dropdown) option.select_by(:value, "x") 

But in my case website that i'm testing doesn't have regular "dropdown" and "options". what i'm facing here

<div class="sk-select"><input maxlength="" type="text" value="" class="sk-select__typing-input"> <!----> <span class="sk-select__value" title="Select a language">Select a language</span> <span class="sk-select__arrow"></span> <!----></div> 

example of html

Before click on the dropdown section

<div class="sk-select"><input maxlength="" type="text" class="sk-select__typing-input"> <!----> <span class="sk-select__value" title="Select a language">Select a language</span> <span class="sk-select__arrow"></span> <!----></div> <span class="sk-select__value" title="Select a language">Select a language</span> 

After click on the dropdown

<div class="sk-select is-opened"><input maxlength="" type="text" value="" class="sk-select__typing-input"> <!----> <!----> <span class="sk-select__arrow"></span> <ul class="sk-select__list"><li class="sk-select__list-item js-list-item">Afrikaans<span class="sk-select__sub-value">The language is not listed in the National Interpreter Register</span> <span class="sk-select__arrow"></span> 
1
  • Instead of a gif, update the question with the relevant text based HTML of the element before and after clicking on the dropdown element.CommentedAug 30, 2022 at 20:16

1 Answer 1

2

I think what you want to do is to do two clicks one to get the dropdown list to appear and one to select a particular item on the dropdown list. If you are using Ruby I would suggest using the Capybara gem to drive interactions with your web site. With this the approach for making a selection would be something like

find('.sk-select').click find('.sk-select__list.js-list-item', text: item_text).click 

if you just wanted to click on say the first item you could use

all('.sk-select__list.js-list-item').first.click 

find and all are methods provided by Capybara.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.