誰でも手助けできますが、動的に生成されたスマートカードを表すボタンの最後のxpath要素(たとえば、633597015500042010)を取得しようとしています。私は以下を試したが、まだ解決策を見つけることができません。キャプチャしようとしているボタンの名前は「選択」です。ボタンの最後の要素
driver.findElement(By.xpath( "// div [@ class = 'select-item']/div)[last()]"))。
<html class="js flexbox flexboxlegacy canvas canvastext postmessage no-websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients no-cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache desktop" lang="en">
<head>
<body class="rwd">
<noscript> <iframe src="//www.googletagmanager.com/ns.html?id=GTM-KZFHXV" height="0" width="0" style="display:none;visibility:hidden"></iframe> </noscript>
<script>
<div class="page-wrapper page-wrapper-delivery">
<div>
<div class="wrapper-wide wrapper-header" style="position: relative;">
<div class="wrapper-wide wrapper-body">
<div class="wrapper">
<div class="main">
<a id="skipnav" tabindex="-1"></a>
<div class="row hidden">
<div class="row">
<div class="row">
<div class="cf"></div>
<div class="row">
<div class="pane base12">
<form class="cf javascript-validate" novalidate="novalidate">
<div class="component checkout-page cf">
<div class="component ticket-item-base ticket-item-checkout cf">
<div class="cf">
<div class="component smart-card-checkout cf">
<div class="component vertical-accordion stag-standard-accordion checkout-accordion parent-accordion cf">
<ul id="accordion-1" class="accordion single-display">
<li class="cf open-li">
<a class="toggle-link open" href="#"> Select/request a smart card </a>
<a class="edit-link secondary-toggle-link" href="#">Edit</a>
<div class="accordion-drop" style="display: block;">
<div class="accordion-content cf">
<div class="component vertical-accordion stag-standard-accordion child-accordion cf">
<ul id="accordion-2" class="accordion multi-display">
<li class="cf open-li">
<a class="toggle-link open" href="#">Select a smart card</a>
<div class="accordion-drop" style="display: block;">
<div class="accordion-content cf">
<div class="info-box">
<form class="select-card-form" novalidate="" method="post">
<input type="hidden" value="SmartCardSelect_6822d668-9a46-4b51-910d-98c701d43fa2" name="FormName">
<input type="hidden" value="e3429d28-e838-4247-9a4e-0b3dc53cf1a7" name="CardId">
<div class="select-item ">
<p>Smart card 1</p>
<button class="submit-btn uniform-button button-smaller button-orange select-address" data-id="633597015500041558">
</div>
</form>
<form class="select-card-form" novalidate="" method="post">
<form class="select-card-form" novalidate="" method="post">
<form class="select-card-form" novalidate="" method="post">
<form class="select-card-form" novalidate="" method="post">
<form class="select-card-form" novalidate="" method="post">
<form class="select-card-form" novalidate="" method="post">
<input type="hidden" value="SmartCardSelect_6822d668-9a46-4b51-910d-98c701d43fa2" name="FormName">
<input type="hidden" value="94888c8a-815c-484e-808c-8d400694b9e9" name="CardId">
<div class="select-item ">
<p>Smart card 7</p>
<button class="submit-btn uniform-button button-smaller button-orange select-address" data-id="633597015500042010">
<span>Select</span>
</button>
</div>
</form>
<form class="select-card-form" novalidate="" method="post">
<form class="select-card-form" novalidate="" method="post">
<form class="select-card-form" novalidate="" method="post">
</div>
</div>
</li>
<li class="cf">
<li class="cf">
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
<div class="component checkout-date-select cf no-end-date">
</div>
</div>
</div>
</div>
<div class="row">
<div class="row">
</div>
</div>
</div>`enter code here`
周りの誰もが、次の場所を検索しようとしている?..- :) – AzMar
HTMLのインデントが役立つだろう。 htmlは完全ではないようですし、必要な要素を持つメインセクションのみをすべてhtmlに投稿する必要はありません。要素の一意の親を識別し、これを試してみてください:// span [text ()= 'Select']/parent :: button – lauda