如何点击在量角器测试在选择框中的选项? [英] How to click on option in select box in Protractor test?

查看:196
本文介绍了如何点击在量角器测试在选择框中的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的量角器端到端的角度应用测试。我想点击的选择框的选择,但我有如下因素误差元素当前不可见,不可操作。

I am using Protractor for end to end testing in Angular application. I am trying to click on option in select box, but i have folowing error Element is not currently visible and may not be manipulated.

我有HTML的这一部分:

I have this part of html:

<select class="form-control" ng-required="true" ng-model="selectedAction.begStatus"
        ng-options="obj as obj.name for obj in allBegStatuses">
</select>

和我有量角器测试此行code的:

And I have this line of code in Protractor test:

element(by.xpath('//select/option[text()="Draft"]')).click();

我要点击值为草稿选项。你也许知道是什么问题?

I want to click on option with value "Draft". Do you know maybe what is the problem?

推荐答案

这个怎么样:

element(by.xpath('//*[@id="controlId"]/option[3]')).click();

这应该在下拉菜单中选择的值。

This should select the value in the drop down.

希望它帮助。

这篇关于如何点击在量角器测试在选择框中的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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