请为表元素创建XPATH

时间:2014-01-22 08:00:25

标签: ruby selenium xpath selenium-webdriver

您能否为以下网络元素创建完整的XPATH

地址1(邮政信箱/农村路线没问题)

如果你给我如何为任何HTML或XML代码创建XPATH,那将是很棒的。

HTML code:

<!DOCTYPE html>
<html>
<head>
<body id="myProfile">
<div id="header">
<div class="wrapperMenu">
<div class="wrapperBodyCreditCenter">
<div id="bodyAll2">
<div>
<div class="fsmWideHero">
<div style="display: block; margin-bottom: 10px;">
<div class="fsmSubHeader"> Please update any information to maintain a clean and current profile. Once the correct information is entered, simply click on the save changes button to update your profile. </div>
<span class="validateError"> </span>
<script src="https://staging.privacyguard.com/ClientScript.aspx?script=FormControl%2fdisableOnSubmit.js&utc=633470607600000000" type="text/javascript">
<form action="/secure/MyProfile.aspx" autocomplete="OFF" name="PGUpdateProfileFormControl" onsubmit="disableSubmission(this)" method="post">
<input type="hidden" value="pgupdateprofile" name="cf">
<input id="__FLOWEVENT" type="hidden">
<input type="hidden" value="5sXZAFNB4Co/JF70jyZ1HHJdIMso9YP2jGmMsyuLQCKC2J0lOg2XDVX2FcLJBS2WMnYD55d7UNLPVXW0yHa6f4WVjmWwwvT0KiwnAY+6v0xpWJZ9fuKe5F2h25Z+aZZwdoEpJtmnYVyvq+znPaYwyQqTV0d3M6bWeBKMt6woDqdtRzUEooyojAzyaMiYFyqosVe5cGarbQWvFZiUJqH3wGRawchSjnjzh/Amy2F8YHZlJFJVWYAQ4PUx8E9GQeShHsCMs2Fg3ToiUemtIpgXaCGMnCby+sCEnRW4SPA3P9/Et2VO/YXsCYSwkfsNsqSAWMnYoicNwJy9ALYny1uAUxgBrv4dELuz+St9CcUrB0w=" name="__FlowState__">
<input type="hidden" value="364" name="__fspayload">
<div id="profileFormHeader"> Personal Information </div>
  <div id="profileFormBody">
  If you wish to change your name, contact the FreeScoresAndMore customer service center at 1-877-787-9002.
 <p>
 <p> </p>
 <table cellspacing="0" cellpadding="2" border="0" summary="">
<tbody>
<tr>
<td width="220" align="left">
<label for="mpadr1">Address 1 (PO Box/Rural Route is ok)</label>
<br>
<input id="mpadr1" type="text" value="123 new address" name="UpdateProfile_Address1" maxlength="25" size="28">
</td>
<td align="left" colspan="2">
<td width="200" valign="top" bgcolor="#FFFFFF" align="left" style="background-color:#EFF0F2;" rowspan="3">
</tr>
<tr>
<tr>
</tbody>
</table>
</div>
 <div id="profileFormHeader"> Membership Information </div>
 <div id="profileFormBody">
 <div id="profileFormHeader"> Subscription Preference </div>
 <div id="profileFormBody">
 <div style="text-align:center;margin-top:10px;">
 </form>
 </div>
 <input type="hidden" value="7iuanXFUppuCMU7T/6LZi09GsdZ2dCYBLeTL/Wfbclc=" name="authToken">
 </div>
 </div>
 <div class="clear" style="padding-bottom:20px;"></div>
 <div id="subFooter">
 <div id="mainFooter">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"   type="text/javascript">
 <script type="text/javascript">
 <script type="text/javascript">
 </body>
 </html>

提前致谢

1 个答案:

答案 0 :(得分:0)

我不认为这是一种神奇的做事方式。那里有很多指南/教程,你可以开始学习。

尽管如此,这是您需要的//label[@for='mpadr1']//label[contains(.,'Address 1')]

的xpath代码