<section class="row line-details-main-section" ng-if="$lineDetails.userFactory.accountData">
<div class="constrain-width-1024">
<div class="col-xs-12 col-md-offset-2 col-md-8">
<div class="row">
<div class="col-xs-12 no-gutter-md no-gutter-lg">
<line-details-multiline form-content="$lineDetails.content" current-line="$lineDetails.currentLine">
<!---->
<div ng-if="$lineDetails.currentLine && $lineDetails.currentLine.details.ctn">
<line-details-plan form-content="$lineDetails.content" current-line="$lineDetails.currentLine">
<line-details-features form-content="$lineDetails.content" current-line="$lineDetails.currentLine">
<line-details-device form-content="$lineDetails.content" current-line="$lineDetails.currentLine">
<line-details-rewards form-content="$lineDetails.content" current-line="$lineDetails.currentLine">
<myc-panel class="line-details-rewards" panel-title="rewardsCtrl.formContent.linedetailsCricketRewardsTitle" collapsible="true" collapsed="rewardsCtrl.planCollapse">
<div class="panel panel-myc col-xs-12 no-gutter" ng-class="{'no-margin-bottom': $panel.last }">
<!---->
<!---->
<div class="clearfix panel-heading has-focus collapsible bg-darkgrey" ng-if="$panel.collapsible" ng-class="{'has-sub-heading': $panel.subHeading}" role="button" aria-controls="grjtg" ng-click="$panel.collapsed = !$panel.collapsed" tabindex="0">
<!---->
<!---->
<!---->
<!---->
<div id="grjtg" class="clearfix panel-body in collapse" ng-if="$panel.isBody" uib-collapse="$panel.collapsible && $panel.collapsed" ng-transclude="body" aria-expanded="true" aria-hidden="false" style="height: auto;">
</div>
</myc-panel>
</line-details-rewards>
</div>
<!---->
</div>
</div>
</div>
</div>
</section>
<!---->
</line-details>
</div>
&#13;
我有一个每次更改xpath的元素,但问题是它会更改ID。 e.g
//*[@id='elrgv']/myc-panel-body/div[1]/div/div
//*[@id='cdtxe']/myc-panel-body/div[1]/div/div
//*[@id='lhyxe']/myc-panel-body/div[1]/div/div
这是3次点击时的3个不同的x路径。我知道如果ID是固定的,但这里的ID正在改变。如何处理。请查看
答案 0 :(得分:0)
如果你观察到你的id是动态的,但你的元素的路径是静态的(意味着你的元素是修复顺序标签,例如myc-panel-body/div[1]/div/div
)所以你可以直接找到元素,如下所示:
//div/myc-panel-body/div[1]/div/div
OR 为了更可靠,您可以使用其他属性找到父元素,例如
//div[@class='clearfix panel-body in collapse']/myc-panel-body/div[1]/div/div