如何从相应的下拉列表中选择值?
HTML
<select _ngcontent-c13="" class="s_patient_profile_input ng-pristine ng-valid ng-touched" formcontrolname="marital_status">
<option _ngcontent-c13="" value="Single">Single</option>
<option _ngcontent-c13="" value="Married">Married</option></select>
<option _ngcontent-c13="" value="Single">Single</option>
<option _ngcontent-c13="" value="Married">Married</option>
答案 0 :(得分:1)
它不需要id
,只要元素是受支持的下拉选择器,您就可以使用任何查找策略。例如,这是xpath
:
Select select = new Select(driver.findElement(By.xpath("//path_to_drop_down")));
select.deselectAll();
select.selectByVisibleText("Value1");