如何在 Selenium 中使用 optgroup select 下拉菜单?
How to select a dropdown with optgroup in Selenium?
<select class="ms-crm-SelectBox" sort="ascending" defaultselected="-1" id="advFindE_fieldListFLDCTL" style="" xpath="1">
<optgroup id="fld" label="Fields">
<option value="xyz_accountnumber" datatype="nvarchar" maxlength="100" title="Account Number">Account Number</option>
<option value="xyz_addsource" datatype="nvarchar" maxlength="100" title="Add Source">Add Source</option>
<option value="xyz_addsourceleadid" datatype="nvarchar" maxlength="100" title="Add Source Lead ID">Add Source Lead ID</option>
</optgroup>
</select>
我正在尝试select帐号,我正在使用python
dropdown_list = Select(self.driver.find_element_by_css_selector('#advFindE_fieldListFLDCTL'))
dropdown_list.select_by_value('xyz_accountnumber')
我收到以下错误
selenium.common.exceptions.ElementNotInteractableException: Message:
element not interactable: Element is not currently visible and may not
be m.
你能帮忙吗?
这似乎对我有用
element = driver.find_element_by_class_name('ms-crm-SelectBox')
element.click()
option = driver.find_element_by_xpath("//option[@value='xyz_addsource']")
option.click()
这是你想要做的吗?
<select class="ms-crm-SelectBox" sort="ascending" defaultselected="-1" id="advFindE_fieldListFLDCTL" style="" xpath="1">
<optgroup id="fld" label="Fields">
<option value="xyz_accountnumber" datatype="nvarchar" maxlength="100" title="Account Number">Account Number</option>
<option value="xyz_addsource" datatype="nvarchar" maxlength="100" title="Add Source">Add Source</option>
<option value="xyz_addsourceleadid" datatype="nvarchar" maxlength="100" title="Add Source Lead ID">Add Source Lead ID</option>
</optgroup>
</select>
我正在尝试select帐号,我正在使用python
dropdown_list = Select(self.driver.find_element_by_css_selector('#advFindE_fieldListFLDCTL'))
dropdown_list.select_by_value('xyz_accountnumber')
我收到以下错误
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: Element is not currently visible and may not be m.
你能帮忙吗?
这似乎对我有用
element = driver.find_element_by_class_name('ms-crm-SelectBox')
element.click()
option = driver.find_element_by_xpath("//option[@value='xyz_addsource']")
option.click()
这是你想要做的吗?