How to get option value of select element

后端 未结 6 1074
故里飘歌
故里飘歌 2021-01-03 23:40

I am trying to get the option value of a select element using Protractor. However, I\'m not able to find the option element.

HTML

&l         


        
6条回答
  •  粉色の甜心
    2021-01-04 00:08

    This will help.

    //check whether the selected value is equal to the expected value.
    expect(element(by.model("model")).getAttribute('value')).toEqual("0");
    
    //catch the selected value
    element(by.model("model")).getAttribute('value').then(function (value) {
       console.log('selected value', value);
    });
    

提交回复
热议问题