How to get selected option value in protractor

后端 未结 2 1234
长发绾君心
长发绾君心 2021-01-16 23:37

How can I get currently selected option value of selectbox?

I have tried below code but it\'s not working.

element(by.css(\'#selectbox\')).all(by.tag         


        
2条回答
  •  攒了一身酷
    2021-01-17 00:10

    You can either use .filter() to filter out the selected option, or target it directly with a CSS selector:

    element(by.css('#selectbox option[selected]'))
    

    Note that there is an overall nicer way to deal/interact with the select in Protractor:

    • Select -> option abstraction

提交回复
热议问题