我能够识别元素upto - span id =“trayCover_page0ivu0”
之后,我无法识别帮助。
我必须点击以下行。
<a class="SItreeText" href="#" style="word-wrap: normal; white-space: nowrap;"></a>
请告诉我执行任何操作以隐藏元素 -
pageSupport._setHtmlbIds("page0ivu0","Tray4b6ce4ad… script
我尝试使用下面不起作用的代码:
//driver.findElement(By.xpath("//a[@style='word-wrap: normal; white-space: nowrap;']"));
// driver.findElement(By.cssSelector("a[class='SItreeText']")).click();
//driver.findElement(By.cssSelector(".SItreeText")).click();
//driver.findElement(By.linkText("Ford CRM Centre")).click();
//driver.findElement(By.xpath("//html/body/table/tbody/tr[1]/td/div[1]/table/tbody/tr/td[1]/div/div/table/tbody/tr/td/span/table/tbody[2]/tr[2]/td[3]/div/div/div[2]/div/a")).click();
//driver.findElement(By.cssSelector("#DetailedNavigationTree")).click();
//driver.findElement(By.xpath("//a[contains(@href, '#')]")).click();
//driver.findElement(By.xpath("//a[@class='SItreeText']")).click();
//driver.findElement(By.cssSelector("#DetailedNavigationTree/navurl.SItreeText")).click();
//driver.findElement(By.xpath("//a[contains(@href, '#')]")).click();
//driver.switchTo().frame(driver.findElement(By.xpath("//html/body/table/tbody/tr[1]/td/div[1]/table/tbody/tr/td[1]/div/div/table/tbody/tr/td/span/table/tbody[2]/tr[2]/td[3]/div/div/div[2]/div/a")));
//driver.findElement(By.xpath("//a[contains(text(),'Ford CRM Centre')]")).click();
//WebElement WE = driver.findElement(By.xpath("//div[@id='DetailedNavigationTree']"));
//driver.findElement(By.cssSelector("#DetailedNavigationTree:state"));
<a class="SItreeText" href="#" style="word-wrap: normal; white-space: nowrap;"></a>
Html代码:
<div id="nav_container_div" class="nav" style="">
<table cellspacing="0" cellpadding="0" style="WIDTH: 100%">
<tbody>
<tr>
<td>
<span id="trayCover_page0ivu0" style="margin:0;padding:0">
<script>
pageSupport._setHtmlbIds("page0ivu0","Tray4b6ce4ad…
</script>
<input id="Tray4b6ce4ad_es" type="hidden" value="false" name="Tray4b6ce4ad_es"></input>
<table id="Tray4b6ce4ad" class="urTrcWhlHdr" cellspacing="0" cellpadding="0" border="0" style="width:100%;" onkeydown="sapUrMapi_Tray_keydown('Tray4b6ce4ad',event);" st="+" ct="TY" cols="1">
<tbody></tbody>
<tbody id="Tray4b6ce4ad-tbd">
<tr class="urTrcSpcRowHdContTrn"></tr>
<tr>
<td class="urTrcBdyNotchTrn"></td>
<td class="urTrcSpcVertLftMidTrn"></td>
<td class="urTrcBodyHdr urTrcBodyBdrHdr" valign="top">
<div class="urTrcBodyHdr urTrcBodyHdrBdr urTrcBodyHdrPd">
<div id="Tray4b6ce4ad-bd">
<!--
EPCF: Component com.sap.portal.navigation.detaile…
-->
<div id="UiServiceToServerDIV" style="{display:none}"></div>
<script></script>
<span id="DetailedNavigationTree:sel" class="SItreeSelColor" style="display:none"></span>
<span id="DetailedNavigationTree:selmark" class="SItreeSelColorMarked" style="display:none"></span>
<div id="DetailedNavigationTree" class="SItree">
<div style="margin-left: 0px; margin-right: 10px; white-space: nowrap;">
<img src="/irj/portalapps/com.sap.portal.design.portaldesigndata/theme…portal/ford_theme/nav/treeview/ico12_treeleaf.gif?7.0.24.1.6"></img>
<img id="DetailedNavigationTree/navurl://cd82866421cb92cf96c103eb19061574" src="/irj/portalapps/com.sap.portal.design.portaldesigndata/themes/portal/ford_theme/common/1x1.gif?7.0.24.1.6"></img>
<a class="SItreeText" href="#" style="word-wrap: normal; white-space: nowrap;"></a>
</div>
<input id="DetailedNavigationTree:state" type="HIDDEN" name="DetailedNavigationTree"></input>
</div>
答案 0 :(得分:0)
尝试使用以下定位器
By.cssSelector("#DetailedNavigationTree a.SItreeText")
By.cssSelector("#DetailedNavigationTree>div>a.SItreeText")
By.cssSelector("table[id*='Tray'] div[id*='Tray'] div#DetailedNavigationTree a")
By.cssSelector("table[id*='Tray'] div[id*='Tray'] div#DetailedNavigationTree>div>a")