Expression XPATH: Comment faire pour selectionner la 2è occurence d'un élément ?
Bonjour,
J'ai un problème avec un site avec lequel je souhaiterai interagir au travers de Selenium. mais problème...les ids changent dynamiquement..Je me tourne alors vers XPATH pour localiser précisément les éléments des pages dont j'ai besoin...En particulier, j'ai besoin d'interagir avec le bouton "More" d'une page...et là nouveau problème : il y a dans le code html deux fois ce bouton (ligne 36 et 90) précédé de la même strucuture html..Comment puis-je faire pour sélectionner le second bouton (ligne 90) et non le premier (ligne 36) ? Pourquoi le second ? parce que c'est celui que FirePath identifie depuis l'IHM..
J'ai créé l'expression suivante mais cela ne fonctionne pas..c'est le 1er bouton qui est sélectionné...
//div[@class=' x-panel x-panel-noborder' AND @style='width: 1136px;']/descendant::button[.='More']
Comment faire svp ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
| <document>
<html id="ext-gen3" class=" ext-strict x-viewport" decorator="blank">
<head>
<body id="ext-gen4" class="ext-gecko3 cwc-view x-border-layout-ct" onload="cwc.getFrameworkWindow()">
<div id="cwc_header" class=" masthead x-border-panel" style="left: 0px; top: 0px; width: 1366px; height: 27px;">
<div id="cwcNavPanel" class=" x-panel cwc-navPanel x-border-panel" style="width: 220px; left: 0px; top: 56px;">
<div id="cwcCenterPanel" class=" x-tab-panel cwc-centerPanel x-border-panel" style="left: 228px; top: 35px; width: 1138px;">
<a id="mainContent"/>
<div id="ext-gen55" class="x-tab-panel-header x-unselectable x-tab-panel-header-plain x-tab-scrolling-top" style="width: 1138px;">
<div id="ext-gen56" class="x-tab-panel-bwrap">
<div id="ext-gen57" class="x-tab-panel-body x-tab-panel-body-top" style="width: 1138px; height: 347px;">
<div id="ext-comp-987100" class="x-panel x-panel-noborder x-hide-nosize" style="width: 1136px;">
<div id="ext-gen65" class="x-panel-bwrap">
<div id="ext-gen66" class="x-panel-body x-panel-body-noheader x-panel-body-noborder" style="width: 1136px; height: 596px;">
<div id="mif-comp-987101" class=" x-panel x-panel-noborder" style="width: 1136px;">
<div id="ext-gen68" class="x-panel-bwrap">
<div id="ext-gen69" class="x-panel-tbar x-panel-tbar-noheader x-panel-tbar-noborder" style="width: 1136px;">
<div id="ext-comp-987099" class="x-toolbar x-small-editor x-toolbar-layout-ct" style="width: 1136px;">
<table class="x-toolbar-ct" cellspacing="0">
<tbody>
<tr>
<td class="x-toolbar-left" align="left">
<table cellspacing="0">
<tbody>
<tr class="x-toolbar-left-row">
<td id="ext-gen204" class="x-toolbar-cell">
<td id="ext-gen206" class="x-toolbar-cell">
<td id="ext-gen208" class="x-toolbar-cell">
<table id="ext-comp-987105" class="x-btn ltr x-btn-noicon" style="width: auto;" cellspacing="0">
<tbody class="x-btn-small x-btn-icon-small-left">
<tr>
<tr>
<td class="x-btn-ml">
<td class="x-btn-mc ">
<em id="ext-gen210" class="x-btn-arrow" unselectable="on" role="menu" aria-haspopup="true">
<button id="ext-gen209" class="x-btn-text" type="button">More</button>
</em>
</td>
<td class="x-btn-mr">
</tr>
<tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
<td class="x-toolbar-right" align="right">
</tr>
</tbody>
</table>
</div>
</div>
<div id="ext-gen70" class="x-panel-body ux-mif-mask-target x-panel-body-noheader x-panel-body-noborder" style="width: 1136px; height: 569px;">
</div>
</div>
</div>
</div>
</div>
<div id="ext-comp-987205" class=" x-panel x-panel-noborder" style="width: 1136px;">
<div id="ext-gen381" class="x-panel-bwrap">
<div id="ext-gen382" class="x-panel-body x-panel-body-noheader x-panel-body-noborder" style="width: 1136px; height: 346px;">
<div id="mif-comp-987206" class=" x-panel x-panel-noborder" style="width: 1136px;">
<div id="ext-gen384" class="x-panel-bwrap">
<div id="ext-gen385" class="x-panel-tbar x-panel-tbar-noheader x-panel-tbar-noborder" style="width: 1136px;">
<div id="ext-comp-987204" class="x-toolbar x-small-editor x-toolbar-layout-ct" style="width: 1136px;">
<table class="x-toolbar-ct" cellspacing="0">
<tbody>
<tr>
<td class="x-toolbar-left" align="left">
<table cellspacing="0">
<tbody>
<tr class="x-toolbar-left-row">
<td id="ext-gen392" class="x-toolbar-cell">
<td id="ext-gen394" class="x-toolbar-cell">
<td id="ext-gen396" class="x-toolbar-cell">
<td id="ext-gen398" class="x-toolbar-cell">
<td id="ext-gen400" class="x-toolbar-cell">
<td id="ext-gen402" class="x-toolbar-cell">
<td id="ext-gen404" class="x-toolbar-cell">
<td id="ext-gen406" class="x-toolbar-cell">
<table id="ext-comp-987215" class="x-btn ltr x-btn-noicon x-btn-over" style="width: auto;" cellspacing="0">
<tbody class="x-btn-small x-btn-icon-small-left">
<tr>
<tr>
<td class="x-btn-ml">
<td class="x-btn-mc ">
<em id="ext-gen408" class="x-btn-arrow" unselectable="on" role="menu" aria-haspopup="true">
<button id="ext-gen407" class="x-btn-text" type="button">More</button>
</em>
</td>
<td class="x-btn-mr">
</tr>
<tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
<td class="x-toolbar-right" align="right">
</tr>
</tbody>
</table>
</div>
</div>
<div id="ext-gen386" class="x-panel-body ux-mif-mask-target x-panel-body-noheader x-panel-body-noborder" style="width: 1136px; height: 319px;">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Telephony Applet -->
<iframe id="ext-gen225" class="ext-shim" src="/sm/js/9.33.4034/extjs/resources/images/default/s.gif" style="display: none; visibility: visible; z-index: 20000; left: 658px; top: 90px; width: 74px; height: 21px;" frameborder="0"/>
<div id="ext-gen76" class="x-shadow" style="z-index: 20001; left: 658px; top: 90px; width: 74px; height: 21px; display: none;">
<div id="ext-comp-987085" class="x-tip" style="position: absolute; z-index: 20002; visibility: hidden; width: 74px; left: 654px; top: 87px; display: none;">
<div id="cwcNavPanel-xsplit" class="x-layout-split x-layout-split-west x-unselectable x-splitbar-h" style="left: 220px; top: 56px; height: 351px;"/>
<div id="ext-gen54" class=" x-unselectable x-splitbar-proxy x-splitbar-proxy-h"/>
<div id="ext-gen226" style="position: absolute; left: -1000px; top: -1000px; visibility: hidden; font-size: 11px; font-style: normal; font-weight: 400; font-family: tahoma,arial,helvetica,sans-serif; line-height: 15px; text-transform: none; letter-spacing: normal; width: auto;"/>
</body>
</html>
</document> |
merci par avance,