Forum Discussion

funmay's avatar
funmay
Contributor
6 years ago
Solved

Select drop down problems

I am having problem to select a drop down item with ClickItem(), it was working before until the tags "select and option" have been replaced with "div".

It was  working with these below html tags with select and options

e.g 

<select id='dropDownMenu'>
  <option value='foo'>Title1</option>
  <option value='bar'>Title2</option>
</select>

but it is not working with the below example for the html  

<div id='dropDownMenu'>
  <div value='foo'>Title1</div>
  <div value='bar'>Title2</div>
</div>

Could you please let me know if there is any other method to select the dropdown without using the ClickItem() 

  • Hi,

     

    The problem is that initially the page had a real dropdown with a set of its items. Thus .SelectItem() method worked.

    Now your page does not have any dropdown but has just a set of unrelated div elements. They are interacting like dropdown only due to some page script code, but not because the browser renders and handle them as a dropdown.

    Your only option is to implement a new test code that will search for the new 'dropdown' (by the value of id, for example) and click the found object in order to 'open' the 'list of dropdown values'. Then the code must search for the required child div, scroll it into view if the found item is not visible on the screen (this can be done with the help of the .scrollIntoView() native DOM method), and click the found item.

     

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    The problem is that initially the page had a real dropdown with a set of its items. Thus .SelectItem() method worked.

    Now your page does not have any dropdown but has just a set of unrelated div elements. They are interacting like dropdown only due to some page script code, but not because the browser renders and handle them as a dropdown.

    Your only option is to implement a new test code that will search for the new 'dropdown' (by the value of id, for example) and click the found object in order to 'open' the 'list of dropdown values'. Then the code must search for the required child div, scroll it into view if the found item is not visible on the screen (this can be done with the help of the .scrollIntoView() native DOM method), and click the found item.