[英]How to perform Protractor testing in md-option
I have the code in angular which is 我有角度的代码是
<md-input-container>
<label>Country </label>
<md-select name="country" ng-model="country"required >
<md-optgroup label="Select Country">
<md-option ng-repeat="item in countryList" ng-value="item" >
{{item.countryName}}
</md-option>
</md-optgroup>
</md-select>
</md-input-container>
and in have used the code in Protractor as following 并在Protractor中使用了以下代码
element(by.model("country")).click();
browser.sleep(2000);
element.all(by.repeater("item in countryList").row('1')).click();
and I am always getting the game error as 而且我总是收到游戏错误
Failed: element not visible
失败:元素不可见
in the code the element(by.model("country")).click() is working fine but not selecting the md-option in popup window please help. 在代码中element(by.model(“ country”))。click()工作正常,但未在弹出窗口中选择md-option,请提供帮助。
Try with below code (You should get 1st element selected. 尝试以下代码(您应该选择第一个元素。
element(by.model("country")).click();
browser.sleep(2000);
element.all(by.repeater("item in countryList").get(1)).click();
If still facing issue You can try to scroll till that element. 如果仍然面临问题,您可以尝试滚动到该元素。
element(by.model("country")).click();
browser.sleep(2000);
var elementToSelect = element.all(by.repeater("item in countryList").get(1));
browser.executeScript('arguments[0].scrollIntoView(true)',elementToSelect.getWebElement());
elementToSelect.click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.