簡體   English   中英

如果在不同的optgroup下選項名稱相同,如何從選擇框中選擇“選項”名稱

[英]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')

SS

您必須將.select()到選擇對象之外。 按值選擇可能會更好。 所以試試這個:

cy .get('select#itemType') .select('Select RadioButtonList');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM