如何获得选择元素的期权价值 [英] How to get option value of select element

查看:124
本文介绍了如何获得选择元素的期权价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让使用量角器一个select元素的期权价值。不过,我无法找到的选项元素。

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

<select ng-options="opions.c as options.n for option in options" ng-model="model">
    <option value="0">Option 1</option>
    <option value="1">Option 2</option>
</select>

规格文件

describe('testing select option', function() {
    it('', function() {
        ptor = protractor.getInstance();

        //This will not get the option required
        ptor.findElement(protractor.By.binding('model'));
    });
});

我似乎无法找到一个方法来抓住期权价值,因为我还没有找到,我可以使用,不给和异常或错误信息的功能。

I cannot seem to find a way to grab the option value as I haven't found a function that I can use that doesn't give and exception or error message.

有谁知道如何解决这个问题呢?

Does anyone know how to resolve this issue?

推荐答案

再次确定我现在已经能弄清楚如何抓住用量角器选项元素。

ok again I have now been able to figure out how to grab the option element with protractor.

这个例子code以下显示了如何做到这一点。

the example code below shows how to accomplish this.

ptor.findElement(protractor.By.css('select option:nth-child(value of the option you require IE: the number)')).click();

这篇关于如何获得选择元素的期权价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆