0

量角器投掷错误失败:索引超出范围。尝试访问索引处的元素: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\") 而不是(contains(@class, \"多标题\"))]// [包含(@class, \"slick-pane slick-pane-bottom slick-pane-left\")]// [包含(@class, \"slick-row\" ) 和后代::*[normalize-space(.)=\"88579YAE\"]]")
4

1 回答 1

0

看起来您可能错过了 eleXpath 上的转义

var eleXpath = '//[@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(@class, "slick-row") and descendant::*[normalize-space(.)="88579YAE"]]';

相对

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")]//[包含(@class, "slick-row") 和后代::*[normalize-space(.)="88579YAE"]]';

于 2016-10-19T02:35:40.787 回答