如何点击watir webdriver中表格内的随机链接?

时间:2014-07-25 13:18:37

标签: ruby watir watir-webdriver

我正在使用salesforce应用程序。我想点击表格内的链接。链接是随机生成的。表格中有2个-3链接。但我想点击特定链接。

下面是我的代码:

DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html class="ext-strict" style="" xmlns:ui="http://www.salesforce.com/ui/accent/sfdccmp/ui" xmlns:config="http://www.salesforce.com/ui/accent/sfdccmp/ui" xmlns:facet="http://www.salesforce.com/ui/accent/sfdccmp/ui" xmlns:data="http://www.salesforce.com/ui/accent/sfdccmp/data" xmlns:chatter="http://www.salesforce.com/ui/accent/sfdccmp/chatter" xmlns:sfdc="http://www.salesforce.com/ui/accent/sfdccmp/sfdc"><head> … </head><body class="hasMotif contractTab  detailPage  ext-gecko ext-gecko3 sfdcBody brandQuaternaryBgr" onbeforeunload="if(this.bodyOnBeforeUnload){var s=bodyOnBeforeUnload();if(s)return s;}" onfocus="if(this.bodyOnFocus)bodyOnFocus();" onunload="if(this.bodyOnUnload)bodyOnUnload();" onload="if(this.bodyOnLoad)bodyOnLoad();">
  <!-- Main Body Starts Here -->
<form id="sessiontimeout" onsubmit="if (window.ffInAlert) { return false; }" name="sessiontimeout" method="post"> … </form><script> … </script><a class="navSkipLink zen-skipLink zen-assistiveText" href="#skiplink"> … </a><div id="contentWrapper"><div id="AppBodyHeader" class="bPageHeader"><table id="phHeader" class="phHeader brandZeronaryBgr" cellspacing="0" cellpadding="0" border="0"> … </table><div class="zen"><div id="tabContainer" class="zen-hasTabOrganizer zen-headerBottom brdPalette" role="navigation"><h1 class="zen-assistiveText"> … </h1><nav><ul id="tabBar" class="zen-inlineList zen-tabMenu"><li id="home_Tab" class="zen-firstItem"> … </li><li id="File_Tab"> … </li><li id="Account_Tab"> … </li><li id="Lead_Tab"> … </li><li id="Opportunity_Tab"> … </li><li id="01r30000001KGS2_Tab"> … </li><li id="report_Tab"> … </li><li id="Dashboard_Tab"> … </li><li id="Chatter_Tab"> … </li><li id="01ra00000014PLY_Tab"> … </li><li id="Case_Tab"> … </li><li id="AllTab_Tab"> … </li><li id="MoreTabs_Tab" class="zen-notNeeded zen-lastItem zen-moreTabs" data-uidsfdc="59"> … </li></ul></nav></div></div></div><div class="bodyDiv brdPalette brandPrimaryBrd"><table id="bodyTable" class="outer" width="100%" cellspacing="0" cellpadding="0" border="0">
  <!-- Start page content table -->
<tbody><tr><td id="sidebarCell" class=" sidebarCell sidebarCollapsible sidebarCollapsed"> … </td><td id="bodyCell" class="oRight">
  <!-- Start page content -->
<a name="skiplink"> … </a><div class="bPageTitle"><div class="ptBody"><div class="content"><img class="pageTitleIcon" title="Contract" alt="Contract" src="/s.gif"></img><h1 class="pageType"> … </h1><h2 class="pageDescription">
   CTR-00276843
</h2><div class="blank"> … </div></div><div class="links"> … </div></div><div id="section_header" class="metadata"> … </div><div id="chatterfeedshell" class="chatterfeedshell"> … </div><script> … </script><div class="ptBreadcrumb"></div></div><script type="text/javascript"> … </script><div id="RLPanelShadow" class="RLPanelShadow" style="display: none;"> … </div><div class="listHoverLinks" style="visibility: visible;"> … </div><script> … </script><script> … </script><div id="ep" class="bPageBlock brandSecondaryBrd bDetailBlock secondaryPalette"><div class="pbHeader"> … </div><div class="pbBody"><div id="errorDiv_ep" class="pbError" style="display: none"> … </div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td class="labelCol">
  Contract Name
</td><td id="Name_ilecell" class="dataCol col02 inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td><td class="labelCol">
  Status
</td><td id="ctrc15_ilecell" class="dataCol inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"><div id="ctrc15_ileinner"> … </div></td></tr><tr><td class="labelCol"> … </td><td id="ctrc2_ilecell" class="dataCol col02 inlineEditLock" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td><td class="labelCol">
  Contract Start Date
</td><td id="ctrc5_ilecell" class="dataCol inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"><div id="ctrc5_ileinner"> … </div></td></tr><tr> … </tr><tr><td class="labelCol">
  Opportunity
</td><td id="CF00Na000000ASdVq_ilecell" class="dataCol col02 inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td><td class="labelCol">
  Owner Expiration Notice
</td><td id="ctrc13_ilecell" class="dataCol inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td></tr><tr><td class="labelCol"> … </td><td id="00Na000000ATFrm_ilecell" class="dataCol col02 inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td><td class="labelCol"> … </td><td id="ctrc1_ilecell" class="dataCol"> … </td></tr><tr><td class="labelCol"> … </td><td id="00Na000000ASdVv_ilecell" class="dataCol col02 inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td><td class="labelCol">
  Billing Representative
</td><td id="CF00Na000000ASdVd_ilecell" class="dataCol inlineEditWrite" tabindex="0" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td></tr><tr> … </tr><tr><td class="labelCol"> … </td><td id="00Na000000AT3UN_ilecell" class="dataCol col02 inlineEditLock" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td><td class="labelCol"> … </td><td id="00Na000000AT3Ty_ilecell" class="dataCol inlineEditLock" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td></tr><tr> … </tr><tr> … </tr></tbody></table></div><div id="head_01Ba000000DcapR_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"><img id="img_01Ba000000DcapR" class="hideListButton" title="Hide Section - Pricing Change Details" tabindex="0" style="cursor:pointer;" onkeypress="if (event.keyCode=='13')twistSection(this);" onclick="twistSection(this);" name="Pricing Change Details" alt="Hide Section - Pricing Change Details" src="/s.gif"></img><h3> … </h3></div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"> … </table></div><div id="head_01Ba000000DcapS_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"><img id="img_01Ba000000DcapS" class="hideListButton" title="Hide Section - Total Summary" tabindex="0" style="cursor:pointer;" onkeypress="if (event.keyCode=='13')twistSection(this);" onclick="twistSection(this);" name="Total Summary" alt="Hide Section - Total Summary" src="/s.gif"></img><h3> … </h3></div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"><tbody><tr> … </tr><tr><td class="labelCol">
  Annual Discount
</td><td id="00Na000000ASdZO_ilecell" class="dataCol col02 inlineEditLock" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"><div id="00Na000000ASdZO_ileinner"> … </div></td><td class="labelCol">
  Total Annual
</td><td id="00Na000000ASdZT_ilecell" class="dataCol inlineEditLock" onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);" onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);" ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);" onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);" onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"> … </td></tr><tr> … </tr><tr> … </tr></tbody></table></div><div id="head_01Ba000000Dce1V_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"><img id="img_01Ba000000Dce1V" class="hideListButton" title="Hide Section - Quote Detail" tabindex="0" style="cursor:pointer;" onkeypress="if (event.keyCode=='13')twistSection(this);" onclick="twistSection(this);" name="Quote Detail" alt="Hide Section - Quote Detail" src="/s.gif"></img><h3> … </h3></div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"> … </table></div><div id="head_01Ba000000DcapT_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"><img id="img_01Ba000000DcapT" class="hideListButton" title="Hide Section - Last Active Contract Total Summary" tabindex="0" style="cursor:pointer;" onkeypress="if (event.keyCode=='13')twistSection(this);" onclick="twistSection(this);" name="Last Active Contract Total Summary" alt="Hide Section - Last Active Contract Total Summary" src="/s.gif"></img><h3> … </h3></div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"> … </table></div><div id="head_01Ba000000DcWtn_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"><img id="img_01Ba000000DcWtn" class="hideListButton" title="Hide Section - Additional Information" tabindex="0" style="cursor:pointer;" onkeypress="if (event.keyCode=='13')twistSection(this);" onclick="twistSection(this);" name="Additional Information" alt="Hide Section - Additional Information" src="/s.gif"></img><h3> … </h3></div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"> … </table></div><div id="head_01Ba000000DcapU_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"><img id="img_01Ba000000DcapU" class="hideListButton" title="Hide Section - Restaurant Address" tabindex="0" style="cursor:pointer;" onkeypress="if (event.keyCode=='13')twistSection(this);" onclick="twistSection(this);" name="Restaurant Address" alt="Hide Section - Restaurant Address" src="/s.gif"></img><h3> … </h3></div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"> … </table></div><div id="head_01B3000000AaoSI_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"><img id="img_01B3000000AaoSI" class="hideListButton" title="Hide Section - Address Information" tabindex="0" style="cursor:pointer;" onkeypress="if (event.keyCode=='13')twistSection(this);" onclick="twistSection(this);" name="Address Information" alt="Hide Section - Address Information" src="/s.gif"></img><h3> … </h3></div><div class="pbSubsection"><table class="detailList" cellspacing="0" cellpadding="0" border="0"> … </table></div><div id="head_01B3000000AaoSJ_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"> … </div><div class="pbSubsection"> … </div><div id="head_01Ba000000Dejvd_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"> … </div><div class="pbSubsection"> … </div><div id="head_01B3000000AaoSK_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"> … </div><div class="pbSubsection"> … </div><div id="head_01Ba000000DcapV_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"> … </div><div class="pbSubsection"> … </div><div id="head_01B3000000AaoSL_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"> … </div><div class="pbSubsection"> … </div><div id="head_01Ba000000Dce1W_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"> … </div><div class="pbSubsection"> … </div><div id="head_01Ba000000DcapW_ep" class="pbSubheader brandTertiaryBrd tertiaryPalette"> … </div><div class="pbSubsection"> … </div></div><div class="pbBottomButtons"> … </div><div class="pbFooter secondaryPalette"> … </div></div><script src="/static/111213/js/picklist.js"></script><script> … </script>
  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_00Na000000ASdVK" class="bRelatedList"><a name="800f00000006U1C_00Na000000ASdVK_target"></a>
  <!-- Begin ListElement -->

  <!-- motif: Contract -->

  <!-- WrappingClass -->
<div class="listRelatedObject customnotabBlock"> … </div><div class="listElementBottomNav"></div><script> … </script>
  <!-- End ListElement -->
</div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_00Na000000ASdVM" class="bRelatedList"><a name="800f00000006U1C_00Na000000ASdVM_target"></a>
  <!-- Begin ListElement -->

  <!-- motif: Contract -->

  <!-- WrappingClass -->
<div class="listRelatedObject Custom18Block"><div class="bPageBlock brandSecondaryBrd secondaryPalette"><div class="pbHeader"> … </div><div id="800f00000006U1C_00Na000000ASdVM_body" class="pbBody"><table class="list" cellspacing="0" cellpadding="0" border="0"><tbody><tr class="headerRow"> … </tr>
  <!-- ListRow -->
<tr class="dataRow even last first" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}"><td class="actionColumn"> … </td><th class=" dataCell  " scope="row"><a href="/a1kf00000007bl0">
  ORD-test_SS_12335_4-Jul-15-2014
</a></th><td class=" dataCell  ">
  Installed/Setup
</td><td class=" dataCell  "> … </td><td class=" dataCell  "> … </td><td class=" dataCell  "> … </td></tr></tbody></table></div><div class="pbFooter secondaryPalette"> … </div></div></div><div class="listElementBottomNav"></div><script> … </script>
  <!-- End ListElement -->
</div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_00Na000000ASdVR" class="bRelatedList"><a name="800f00000006U1C_00Na000000ASdVR_target"></a>
  <!-- Begin ListElement -->

  <!-- motif: Contract -->

  <!-- WrappingClass -->
<div class="listRelatedObject assetBlock"><div class="bPageBlock brandSecondaryBrd secondaryPalette"><div class="pbHeader"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td class="pbTitle"><img class="minWidth" width="1" height="1" title="" alt="" src="/s.gif"></img><img class="relatedListIcon" title="" alt="" src="/s.gif"></img><h3 id="800f00000006U1C_00Na000000ASdVR_title"> … </h3></td><td class="pbButton"> … </td><td class="pbHelp"> … </td></tr></tbody></table></div><div id="800f00000006U1C_00Na000000ASdVR_body" class="pbBody"> … </div><div class="pbFooter secondaryPalette"> … </div></div></div><div class="listElementBottomNav"></div><script> … </script>
  <!-- End ListElement -->
</div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_RelatedActivityList" class="bRelatedList"><a name="800f00000006U1C_RelatedActivityList_target"></a>
  <!-- Begin ListElement -->

  <!-- motif: Contract -->

  <!-- WrappingClass -->
<div class="listRelatedObject taskBlock"> … </div><div class="listElementBottomNav"></div><script> … </script>
  <!-- End ListElement -->
</div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_RelatedHistoryList" class="bRelatedList"> … </div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_00Na000000AT3VB" class="bRelatedList"> … </div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_RelatedNoteList" class="bRelatedList"><a name="800f00000006U1C_RelatedNoteList_target"></a>
  <!-- Begin ListElement -->

  <!-- motif: Contract -->

  <!-- WrappingClass -->
<div class="noStandardTab"> … </div><div class="listElementBottomNav"></div><script> … </script>
  <!-- End ListElement -->
</div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_00N3000000A6gu9" class="bRelatedList"> … </div>
  <!-- End RelatedListElement -->

  <!-- Begin RelatedListElement -->
<div id="800f00000006U1C_RelatedEntityHistoryList" class="bRelatedList"><a name="800f00000006U1C_RelatedEntityHistoryList_target"></a>
  <!-- Begin ListElement -->

  <!-- motif: Contract -->

  <!-- WrappingClass -->
<div class="noStandardTab"> … </div><div class="listElementBottomNav"></div><script> … </script>
  <!-- End ListElement -->
</div>
  <!-- End RelatedListElement -->
<div class="fewerMore"> … </div><script> … </script>
  <!-- Body events -->
<script type="text/javascript"> … </script><div id="datePicker" class="datePicker"> … </div>
  <!-- End page content -->
</td></tr></tbody></table></div><div class="bPageFooter noTableFooter"> … </div><div></div></div><script> … </script><script src="/jslibrary/1402506602000/sfdc/ChatterDefer.js" defer="true"></script><script src="/jslibrary/1404472812000/sfdc/Zen.js" defer="true"></script><script> … </script><script async="" defer="" src="/jslibrary/1400606638000/sfdc/SfdcSessionBase190.js"></script><iframe title="sessionserver" style="position: absolute; top: -999px; left: -999px;" src="https://test.salesforce.com/login/sessionserver190.html"></iframe><div id="devSlide" style="display: block;"> … </div><div id="InlineEditDialog" class="overlayDialog cssDialog inlineEditDialog" role="dialog" aria-live="assertive" aria-describedby="InlineEditDialogTitle" style="margin-top: 0px; margin-left: 0px;"> … </div></body></html>
  <!-- page generation time: 1564ms -->



I want to click <a href="/a1kf00000007bl0">ORD-test_SS_12335_4-Jul-15-2014</a> link.

用户界面如下所示:

行动订单订单状态项目协调员ROS记录类型 编辑| Del ORD-test_SS_12335_4-Jul-15-2014已安装/设置Marta Vovchenko系统安装

这里编辑| del是链接。但我想点击ORD-test_SS_12335_4-Jul-15-2014链接。

2 个答案:

答案 0 :(得分:0)

假设只返回了一个表。

browser.element(:css => "th.dataCell a").click

browser.link(:css => "th.dataCell a").click

将仅点击&#34; ORD-test_SS_12335_4-Jul-15-2014&#34;元件

如果您有多行,您可能会进一步过滤选择器

browser.link(:css => "tr.dataRow.even th.dataCell a").click
browser.link(:css => "tr.dataRow.last th.dataCell a").click
browser.link(:css => "tr.dataRow.first th.dataCell a").click

答案 1 :(得分:0)

通常链接不是完全随机的 - 即应该知道“ORD-test_SS_12335_4-Jul-15-2014”的某些部分。例如,“测试”部分似乎不是随机的。因此,您可以尝试通过部分文本查找链接:

browser.link(:text => /test/).click

如果这不起作用,您可以找到该表并单击第th个元素链接:

table = browser.table(:class => 'list')
table.th.link.click

看起来表格中可能还有其他元素,所以你可能只能点击最后一个链接:

table = browser.table(:class => 'list')
table.links.last.click