У меня есть такая таблица JS Fiddle Here
<table class="x-grid-table x-grid-table-resizer" border="1" >
<tbody>
<tr class="x-grid-header-row">
<th class="x-grid-col-resizer-h1" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h2" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h3" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h4" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h5" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h6" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h7" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h8" style="width: 0px; height: 0px;"></th>
<th class="x-grid-col-resizer-h9" style="width: 0px; height: 0px;"></th>
</tr>
<tr class="x-grid-row x-grid-row-ticket-priority">
<td class="justify-content-left x-grid-cell x-grid-cell-h1 ">
<div class="x-grid-cell-inner " style="; text-align: left;">1</div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h2 ">
<div class="x-grid-cell-inner " style="; text-align: left;">Fri Nov 30 2018 19:52:48 GMT+0100 (Central European Standard Time)</div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h3 ">
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h4 ">
<div class="x-grid-cell-inner " style="; text-align: left;">false</div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h5 ">
<div class="x-grid-cell-inner " style="; text-align: left;" id="ext-gen1193"><a href="https://example.com/account/user/profile" class="">blue@example.com</a></div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h6 ">
<div class="x-grid-cell-inner " style="; text-align: left;"> blue@example.com</div>
</td>
<td class="justify-content-center x-grid-cell x-grid-cell-h7 ">
<div class="x-grid-cell-inner " style="; text-align: center;"><a href="javascript:void(0);" id="override_lnk_ext-gen1171">None</a></div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h8 ">
<div class="x-grid-cell-inner " style="; text-align: left;"><a href="javascript:void(0);" id="override_lnk_ext-gen1172">View</a></div>
</td>
<td class="x-row-el-ignore actionsColumn justify-content-center x-grid-cell x-grid-cell-h9 x-grid-cell-last">
<div class="x-grid-cell-inner " style="; text-align: center;">
<div id="splitbutton-user7415249" class="x-btn x-row-el-ignore x-row-el-ignore actionsSplitBtn x-btn-default-small x-icon-text-right x-btn-icon-text-right x-btn-default-small-icon-text-right"><em id="splitbutton-user7415249-btnWrap" class="x-btn-split x-btn-split-right"><button id="splitbutton-user7415249-btnEl" type="button" hidefocus="true" role="button" autocomplete="off" class="x-btn-center x-row-el-ignore" aria-haspopup="true"><span id="splitbutton-user7415249-btnInnerEl" class="x-btn-inner" style="margin:-13px -18px -13px -18px">Actions</span><span id="splitbutton-user7415249-btnIconEl" class="x-btn-icon fa fa-angle-down"> </span></button></em></div>
<div id="ext-gen1173"></div>
</div>
</td>
</tr>
<tr class="x-grid-row x-grid-row-ticket-priority">
<td class="justify-content-left x-grid-cell x-grid-cell-h1 ">
<div class="x-grid-cell-inner " style="; text-align: left;">2</div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h2 ">
<div class="x-grid-cell-inner " style="; text-align: left;">Fri Nov 30 2018 19:52:48 GMT+0100 (Central European Standard Time)</div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h3 ">
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h4 ">
<div class="x-grid-cell-inner " style="; text-align: left;">false</div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h5 ">
<div class="x-grid-cell-inner " style="; text-align: left;" id="ext-gen1193"><a href="https://example.com/account/user/profile" class="">red@test.com</a></div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h6 ">
<div class="x-grid-cell-inner " style="; text-align: left;">red@test.com</div>
</td>
<td class="justify-content-center x-grid-cell x-grid-cell-h7 ">
<div class="x-grid-cell-inner " style="; text-align: center;"><a href="javascript:void(0);" id="override_lnk_ext-gen1171">None</a></div>
</td>
<td class="justify-content-left x-grid-cell x-grid-cell-h8 ">
<div class="x-grid-cell-inner " style="; text-align: left;"><a href="javascript:void(0);" id="override_lnk_ext-gen1172">Generate</a></div>
</td>
<td class="x-row-el-ignore actionsColumn justify-content-center x-grid-cell x-grid-cell-h9 x-grid-cell-last">
<div class="x-grid-cell-inner " style="; text-align: center;">
<div id="splitbutton-user7415249" class="x-btn x-row-el-ignore x-row-el-ignore actionsSplitBtn x-btn-default-small x-icon-text-right x-btn-icon-text-right x-btn-default-small-icon-text-right"><em id="splitbutton-user7415249-btnWrap" class="x-btn-split x-btn-split-right"><button id="splitbutton-user7415249-btnEl" type="button" hidefocus="true" role="button" autocomplete="off" class="x-btn-center x-row-el-ignore" aria-haspopup="true"><span id="splitbutton-user7415249-btnInnerEl" class="x-btn-inner" style="margin:-13px -18px -13px -18px">Actions</span><span id="splitbutton-user7415249-btnIconEl" class="x-btn-icon fa fa-angle-down"> </span></button></em></div>
<div id="ext-gen1173"></div>
</div>
</td>
</tr>
</tbody>
</table>
В каждой строке 5-го столбца содержится электронное письмо, а в 8-м столбце всегда есть кнопка, которая может содержать текстView
или Generate
.
Итак, у меня есть электронное письмо, например, red@test.com
, и я хочу проверить, существует ли оно в какой-либо строке в 5-м столбце, и если оно существует, в этой строкеЯ хочу получить текст кнопки в 8-м столбце этой строки и затем щелкнуть ее.
Я использую машинопись и Puppeteer.
Я решил решить эту проблему, получив все данные таблицы и затем отфильтровав данные таблицы на основе значения 5-го столбца.
const data = await this.page.$$eval(
'table tr td',
tds => tds.map((td) => {
return td.innerHTML; }));
На const data
я получаю все данные таблицы, но таким образом их сложно отфильтровать.
Я пытался настроить таргетинг на электронную почту с помощью селектора запросов let email
Я не получаю никаких данных?
let email = await this.page.evaluate( () => Array.from(
document.querySelectorAll( 'tbody > .x-grid-row > td:nth-child(5)' ), element => {
if(element.textContent.trim() == 'red@test.com') { }} ) );
Может ли кто-нибудь помочь мне добиться этого?