Winium.Desktop icon indicating copy to clipboard operation
Winium.Desktop copied to clipboard

Combo box selected value

Open krishnakanth19 opened this issue 7 years ago • 11 comments

When I,m trying to get the selected value from a combo box it is throwing an error like "unsupported command exception". I used the following code.

Select locatoin = new Select(driver.findElement(By.id("cmbLocation"))); String option = locatoin .getFirstSelectedOption().getText();

What are the other possible ways to get the selected option?

krishnakanth19 avatar Sep 20 '17 11:09 krishnakanth19

here what I did for selecting the combo, try using one of the below method to get values of dropdown -

public void select_combo_by_id(String ID,String select_text){ WebElement env_combo = driver.findElement(By.id(ID)); ComboBox debs_combo = new ComboBox(env_combo); debs_combo.expand(); driver.findElement(By.name(select_text)).click(); }

SanjeevKumarmn avatar Sep 20 '17 14:09 SanjeevKumarmn

Thanks for your response.But what I need is to get which option is selected.

krishnakanth19 avatar Sep 20 '17 14:09 krishnakanth19

new Select is unsupported command. find your combo box and try to get text directly.

heilwood avatar Sep 26 '17 16:09 heilwood

The following are the element properties of a combo box. It is selected as "No". Can you suggest me how to get the selected element?

githubb

krishnakanth19 avatar Sep 27 '17 09:09 krishnakanth19

value pattern for this element is supported or not? i need to know what patterns this combo box supporting. You can check in inspect or UI verify

heilwood avatar Oct 26 '17 09:10 heilwood

It is showing "Value Pattern Available" as "False". combo

krishnakanth19 avatar Nov 01 '17 10:11 krishnakanth19

Hi , I have just started with winium i h ave tried the above code but there is an error in combobox. please let me know the package which needs to added

noopur30 avatar Apr 10 '18 07:04 noopur30

my code c# public void SelectValue(IWebElement elem, string valueText) { var cmb = elem.ToComboBox(); cmb.Expand(); var Actions = new Actions(_driver); var s = new Stopwatch(); s.Start(); while (!elem.FindElement(By.Name(valueText).Displayed) && s.Elapsed < TimeSpan.FromSeconds(10)) { Actions.SendKeys(Keys.PageDown).Perform(); } elem.FindElement(By.Name(valueText)).Click(); s.Stop();}`

I'm not sure that this line of code will work Actions.SendKeys(Keys.PageDown).Perform(); because i fully re-wrote keyboard libraries, but you can try.

heilwood avatar Apr 10 '18 12:04 heilwood

Hello,

I had a similar issue but at the end, I managed to get the selected value from a combo-box with the below code:

ComboBox comboBox = new ComboBox(anElement); String value = comboBox.getAttribute("Name");

Hope this helps!

Br, Sotiris

SotirisAnt avatar Apr 16 '18 12:04 SotirisAnt

Hello,

I am facing the same issue when trying to get the value set in combobox. Anyone has a solution for this?

Thanks, Deepika

Deepika2792 avatar Feb 11 '20 10:02 Deepika2792

Hello, I am using Java with Winium and I'm having a problem to select an option from the drop down. Using Inspect I can locate dropdown with name/AutomationId but not the options, so I can click on drop down but can not select any option. Is there anyone can help me out here?Thank you!

rahib520 avatar Apr 07 '21 17:04 rahib520