[英]How to select 'option' name from a select box if the option name are identical under different optgroup
如果在不同的optgroup
下,選項名稱相同,我們如何從select box
選擇所需的選項(請參閱所附的html標簽屏幕截圖)。 我嘗試了以下方法,但是沒有一種對我有用,任何建議都非常有幫助。
cy.get('option[value="Select RadioButtonList"]').select("Radio buttons (Single-select)")
// 要么
cy.get('#itemType').select('Radio buttons (Single-select)').should('have.value', 'Select RadioButtonList')
// 要么
cy.get('#itemType').then(function($select){
$select.val('Select RadioButtonList')
})
// 要么
cy.get('select').should('have.value', 'Select RadioButtonList')
您必須將.select()
到選擇對象之外。 按值選擇可能會更好。 所以試試這個:
cy .get('select#itemType') .select('Select RadioButtonList');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.