I am trying to access a table on a webpage and within the table trying to click on that cell.
the cell I am trying to reach has an td id="flowTile_6". Highlight it below.
I have tried various means
such as
ch.FindElementByXPath("//table[@id="mainFlow"]/tbody/tr[7]/td[15]").Click
this will error out.
and trying to loop through in a for each to get to it, I have no success.
Option Explicit
Private ch As Selenium.ChromeDriver
Sub test()
Dim FindBy As New Selenium.By
Dim ResultSections As Selenium.WebElements
Dim ResultSection As Selenium.WebElement
Dim TableByTag As Selenium.WebElement
Dim tr, c, r, td, li, cc, t
Set ch = New Selenium.ChromeDriver
ch.Start baseUrl:=""
ch.Get "/"
' ch.FindElementById("flowTile_6").Click
'Set TableByTag = ch.FindElementByTag("table")
'ch.FindElementByXPath("//table[@id="mainFlow"/tbody/tr[7]/td[15]").Click
For Each li In ch.FindElementById("mainFlow")
cc = 1
For Each t In li.FindElementsByTag("li")
ch.FindElementById("flowTile_6").Click
cc = cc 1
Next t
Next li
End Sub
html
<div class="background">
<div class="holder">
<table class="flow" id="mainFlow" style="display: table;">
<tbody>
<tr class="collapsible" id="flowHeader1_text" isasection="true" onclick="doExpandCollapse(this)">
►<td colspan="25">...</td>
</tr>
<tr id="flowHeader1_underline">
<td colspan="25">
<div class="flowHeaderUnderline"></div>
</td>
</tr>
<tr id="flowHeader1_placeholder" class="sectionAnimationPlaceHolder">
<td colspan="25"></td>
</tr>
<tr id="row1">...</tr> == $0
<tr id="row2" class="narrowSpacer">...</tr>
►<tr id="row3" class="narrowSpacer">...</tr>
<<tr id="row4">
<td class="a Em"X/td>
<td class="b Em"x/td>
<td class="a Em"></td>
<td class="d Em"x/td>
►<td id="flowTile_4" class="e item enabled hasIcon" role="link" aria-labelledby="tileDescription_4" havebox="true" formid="W4021B" tiletext="Supply/Demand Inquiry" appid="P4021" version="PSA0001" onclick
script:runE1App (P4021', 'W4021B', 'PSA0001')" onmouseover="javascrpt: startHoverTimer(this);" onmouseout="javascript:startTimerToMaybe End HoverMode (this);">...</td>
<td class="a Em"X</td>
<td class="b Em"X/td>
<td class="a Em"X/td>
<td class="d Em"x/td>
►<td id="flowTile_5" class="e item enabled hasIcon" role="link" aria-labelledby="tileDescription_5" havebox="true" formid="W41202A" tiletext="Item Availability" appid="P41202" version="PSA0001" onclick="
ript:runElApp('P41202', 'W41202A', 'PSA0001')" onmouseover="javascrpt:startHoverTimer(this);" onmouseout="javascript:startTimerToMaybe EndHoverMode(this);">.</td>
<td class="a Em"X/td>
<td class="b Em"></td>
<td class="a Em">/td>
<td class="d Em"X/td>
**<<td id="flowTile_6" class="e item enabled hasIcon" role="link" aria-labelledby="tileDescription_6" havebox="true" formid="W41016" tiletext="Item Master Inquiry" appid="P4101" version="PSA0001" onclick="
ript:runE1App('P4101', 'W4101E','PSA0001')" onmouseover="javascrpt:startHoverTimer(this);" onmouseout="javascript:startTimerToMaybeEndHoverMode (this);">
<div class="relativeWrapper">
<img id="flowTileIconImg_6" size="medium" src="/ide/share/images/ideicons/supply chain mntn medium.png" autoreplace="true">**
<div>
<div class="wlTileDesciption" id="tileDescription_6">Item Master Inquiry</div> == $0
</div>
</div>
</td>
<td class="a Em"X/td>
<td class="b Em"></td>
<td class="a Em"X/td>
<td class="d Em"x/td>
><td id="flowTile_7" class="e item enabled hasIcon" role="link" aria-labelledby="tileDescription_7" havebox="true" formid="W302016" tiletext="Single Level Where Used" appid="P30201" version="PSA0001" onclick=
"javascript:runE1App ("P30201', 'W302013', PSA0001')" onmouseover="javascrpt:startHoverTimer(this);" onmouseout="javascript:startTimerToMaybe EndHoverMode(this);">.</td>
<td class="a Em"x/td>
<td class="b Em"></td>
<td class="a Em"x/td>
<td class="d Em"X/td>
<td class="e Em"X/td>
</tr>
><tr id="rows" class="narrowSpacer">...</tr>
><tr id="row6" class="narrowSpacer">.</tr>
</tbody>
</table
</div>
远。
this is what i am trying to get to within the table
<<td id="flowTile_6" class="e item enabled hasIcon" role="link" aria-labelledby="tileDescription_6" havebox="true" formid="W41016" tiletext="Item Master Inquiry" appid="P4101" version="PSA0001" onclick="
ript:runE1App('P4101', 'W4101E','PSA0001')" onmouseover="javascrpt:startHoverTimer(this);" onmouseout="javascript:startTimerToMaybeEndHoverMode (this);">
<div class="relativeWrapper">
<img id="flowTileIconImg_6" size="medium" src="/ide/share/images/ideicons/supply chain mntn medium.png" autoreplace="true">
CodePudding user response:
It was nested in two iframes.
was able to solve by:
With ch
.SwitchToFrame .FindElementById("e1menuAppIframe", timeout:=10000)
.SwitchToFrame .FindElementById("wcFrame0", timeout:=10000)
Set ResultSections = .FindElementsByClass("flow")
For Each ResultSection In ResultSections
.FindElementById("flowTile_6").Click
Next ResultSection
End With