如何点击在量角器测试在选择框中的选项?量角器、框中、选项、测试

2023-09-14 00:16:40 作者:太阳是我搓圆滴

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

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.

希望它帮助。