Winium.Desktop
Winium.Desktop copied to clipboard
Combo box selected value
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?
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(); }
Thanks for your response.But what I need is to get which option is selected.
new Select is unsupported command. find your combo box and try to get text directly.
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?
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
It is showing "Value Pattern Available" as "False".
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
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.
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
Hello,
I am facing the same issue when trying to get the value set in combobox. Anyone has a solution for this?
Thanks, Deepika
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!