【发布时间】:2016-10-17 20:54:11
【问题描述】:
量角器投掷错误失败:索引超出范围。试图访问 index: 0 处的元素,但只有 0 个元素与定位器 By.xpath 匹配
var eleXpath = '//*[@data-qa-class="tile" and descendant::*[normalize-space(.)="Weights"]]//*[@options="ctrl.grid.options"]/*[contains(@class, "slick-frozen-rows") and not(contains(@class, "multi-header"))]//*[contains(@class, "slick-pane slick-pane-bottom slick-pane-left")]//*[contains(@class, "slick-row") and descendant::*[normalize-space(.)="88579YAE"]]';
var rowReferenceXpath = element.all(by.xpath(eleXpath)).get(rowIndex);
rowReference.isPresent().then(function (isRowPresent) {
if (!isRowPresent) {
// If required row is not found reject the promise with error message
defer.reject('"' + rowName + '" row is not found in the calculated reported.');
} else {
// Get the "style" attribute value of the row
var eleRefs = rowReference.getAttribute('style');
};
抛出错误
- 失败:索引超出范围。试图访问索引为 0 的元素,但只有 0 个元素与定位器匹配 By.xpath("//[@data-qa-class="tile" and descendant::[normalize- space(.)="Weights"]]//[@options="ctrl.grid.options"]/[contains(@class, "slick-frozen-rows") 和 not(contains (@class, "multi-header"))]//[contains(@class, "slick-pane slick-pane-bottom slick-pane-left")]//[contains(@类, "slick-row") 和后代::*[normalize-space(.)="88579YAE"]]")
【问题讨论】:
-
您正在使用的 xpath 没有返回任何元素。这就是量角器抛出此错误的原因。也发布您的 HTML 代码。
-
感谢您的意见,将分享它
标签: protractor gulp-protractor protractor-net