[TestComplete JS] ClickItem() is not working for dropdown
- 6 years ago
Hi,
Just wanted to provide an update: I was finally able to resolve the issue. Thought I could describe it here, to help anyone else reading this post.
Issue: Unable to click on dropdown element to select a desired element. The dropdown is on Select type.
Resolution:
Entire select webelement was getting identified but when I try to identify any 1 of the <option> webelements, it never used to identify. It used to return as an object or null.
So, the solution I came up with is to identify the dropdown <select> by using native DOM method in JavaScript. Then use the selectedIndex property to find out the index of the <option> element which is already selected by default and replace it with desired index of the <option> webelement which you want to select.
Example:
let page = Sys.Browser("*").Page("url");
let selectObj = page.contentDocument.querySelector('abc'); //replace with css selector of Select dropdown
//code to get the index of the <option> webelement which needs to be selected
selectObj.selectedIndex=index;
The above statement will select based on the index of the <option> webelement