Используя Python 3.7 с Selenium на страницах, которые включают Angular, посоветуйте, пожалуйста, как лучше всего найти такой элемент, как этот:
<input type="radio" ng-model="section3.data.generalSection3.container[$index].lseCatTy" value="FEDERAL" ng-disabled="!section3.data.generalSection3.container[$index].editable" ng-class="classes('lseCatTy')" ng-change="section3.updateLseCatTy($index, section3.data.generalSection3.container[$index].lseCatTy)" class="ng-valid ng-not-empty ng-dirty ng-touched ng-valid-parse" name="759" style="">
или этот
<button type="button" uib-tooltip="Edit" tooltip-placement="right" class="btn btn-primary" ng-click="section3.data.editContainer($index);" ng-disabled="editingDrilling1 || submissionTypeSR">
когда он существует в таких блоках, как следующие. Что меня сбивает с толку, так это $ index ... На странице есть несколько тегов fieldset
, и этот номер - DYNAMI C ... Например, пользователь может добавить несколько тегов одного типа fieldset
при редактировании страницы - но только этот тип.
<div ng-if="section3.data.generalSection3.srvyTyId != null && section3.data.generalSection3.srvyTyId != ''" class="ng-scope" style="">
<!-- ngRepeat: wellFeature in section3.data.generalSection3.container track by $index -->
<div ng-repeat="wellFeature in section3.data.generalSection3.container track by $index" class="ng-scope">
<!-- ngIf: section3.data.generalSection3.container[$index].deleteSegmentLocation == null -->
<fieldset class="legend-border ng-scope" ng-if="section3.data.generalSection3.container[$index].deleteSegmentLocation == null">
<legend/>
<div class="col-lg-12 panel panel-default">
<div class="row panel-heading ng-binding">
SHL <br>
<!-- ngIf: section3.data.generalSection3.container[$index].legBHLAttr == 'PPP' -->
<!-- ngIf: section3.data.generalSection3.container[$index].legBHLAttr != 'PPP' && section3.data.generalSection3.container[$index].legBHLAttr != 'SHL' -->
<!-- ngIf: section3.data.generalSection3.container[$index].legBHLAttr == 'SHL' -->
<div ng-if="section3.data.generalSection3.container[$index].legBHLAttr == 'SHL'" class="ng-scope"/>
<!-- end ngIf: section3.data.generalSection3.container[$index].legBHLAttr == 'SHL' -->
</div>
</div>
<div class="row">
<div class="col-lg-11">
<!-- ngIf: section3.data.generalSection3.srvyTyId=='1'|| section3.data.generalSection3.srvyTyId=='3' || section3.data.generalSection3.srvyTyId=='2' || section3.data.generalSection3.srvyTyId=='4' -->
<div ng-if="section3.data.generalSection3.srvyTyId=='1'|| section3.data.generalSection3.srvyTyId=='3' || section3.data.generalSection3.srvyTyId=='2' || section3.data.generalSection3.srvyTyId=='4'" style="padding-left: 15px; padding-right: 15px;" class="ng-scope">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label class="required-field">Lease Type</label>
<br>
<div ng-class="classes('lseCatTy'+','+$index.toString(), [])">
<label class="radio-inline">
<input type="radio" ng-model="section3.data.generalSection3.container[$index].lseCatTy" value="FEDERAL" ng-disabled="!section3.data.generalSection3.container[$index].editable" ng-class="classes('lseCatTy')" ng-change="section3.updateLseCatTy($index, section3.data.generalSection3.container[$index].lseCatTy)" class="ng-valid ng-not-empty ng-dirty ng-touched ng-valid-parse" name="759" style=""> Federal
</label>
<label class="radio-inline">
То, что у меня работает:
self.wait.until(EC.presence_of_element_located((By.XPATH, "//button[@ng-click='section3.data.editContainer($index);']"))).click()
И это получает первый экземпляр этой кнопки (в верхнем наборе полей), но я не Не знаю, как получить его произвольный экземпляр.