English 中文(简体)
我如何从一次java试验中 se素的 drop滴菜中选择一种选择?
原标题:How can I select an option from a dropdown menu in selenide in a java test?

我需要利用 se素进行 j瓦试验,通过在线平台自动进行,我无法找到从某个下游名单上选择的办法。 我曾尝试过几部法典。 但是,使用<代码>Selectdown = 新的选择性(driver.findElement(By.id("id_of_the_dropdown_list”);作为该守则的基础没有发挥作用,而是试图:

SelenideElement menueGesamt = $(By.id("id_of_the_dropdown_list"));
        ElementsCollection optionen = menueGesamt.findAll(By.cssSelector("option"));
        int maxRandom = optionen.size();
        int random = new Random().nextInt(maxRandom);
        SelenideElement gewaehlteOption = optionen.get(random);
        String optionValue = gewaehlteOption.getAttribute("value");
        menueGesamt.selectOptionByValue(optionValue);

但这也无所作为。 没有任何错误,但选择不选择。 图像显示应发生什么情况,应选择选择方案,然后倒塌的菜单应关闭。

“enterography

问题回答

Can you show more information please? Your HTML like this? Has "option value"?

<select id="dropdownListId">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>

If your HTML is not like this then Selenide will not work.

You need use method click() for select element of dropdown list





相关问题
WPF Datagrid, Setting the background of combox popup

I would like to change the color of the popup background when using a DatagridComboboxColumn in the WPF Toolkit datagrid. I ve edited the Template for a normal Combobox and it works great for selected ...

How to insert ComboBox item into ListBox? [winforms]

The question is very simple, How to insert ComboBox selected item into ListBox using c#? I have tried with this: listbox.Items.Add(combobox.SelectedItem); and some other permutations but it always ...

How do I bind a ComboBox to a one column list

I ve seen how to bind a ComboBox to a list that has columns like this: ItemsSource="{Binding Path=Entries}" DisplayMemberPath="Name" SelectedValuePath="Name" SelectedValue="{Binding Path=Entry}" But ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

热门标签