How to get option value of select element

后端 未结 6 1104
故里飘歌
故里飘歌 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

    In order to enumerate the option tags you can try to use the .all method and you should access it by the parent first.

    element(by.model('model')).all(by.tagName('option')).then(function(arr) {
            expect(arr.length).toEqual(2);
    });
    

    Have a look at the API reference for inspiration

    http://www.protractortest.org/#/api?view=ElementArrayFinder.prototype.all

    Edit: also follow the style guide which discourages usage of XPath http://www.protractortest.org/#/style-guide

提交回复
热议问题