下午好,
我正在尝试从网页上的元素(列表)中获取所有文本:
我尝试了以下代码,但未成功:
WebElement bodyText = driver0.findElement(By.xpath("//*[@id=\"u_resultadochassi_case_table\"]"));
String Souce_code = bodyText.getAttribute("outerHTML");
System.out.println(Souce_code);
基本上,我只需要从以下位置获取信息:
UF Gravame- 努美洛- 通知数据- 查西- 广场- Ofício- 数据自由
如果我可以从网格或externalHTML中获取所有文本,则可以继续进行开发
附加页面部分的源代码:
<tbody class="list2_body"><tr id="row_u_resultadochassi_case___ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=" class="list_row list_odd list_row_compact" style="" sys_id="__ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=" record_class="u_resultadochassi_case" collapsed="true" data-type="list2_row" data-list_id="u_resultadochassi_case"><td class="list_decoration_cell col-control col-small col-center " style="white-space:nowrap;" rowspan="1"><span class="input-group-checkbox"><input type="checkbox" title="Marcar registro para Ação de lista" id="check_u_resultadochassi_case___ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=" name="check_u_resultadochassi_case" class="checkbox " data-type="list2_checkbox" data-list_id="u_resultadochassi_case" data-original-title="Marcar registro para Ação de lista"><label for="check_u_resultadochassi_case___ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=" style="" class="checkbox-label"><span class="sr-only">Selecione o registro para ação: __ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=</span></label></span></td><td class="list_decoration_cell col-small col-center " rowspan="1"><a href="u_resultadochassi_case.do?sys_id=__ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=&sysparm_view=Ralatório&sysparm_record_target=&sysparm_record_row=1&sysparm_record_list=resultado_u_processoISNOTEMPTY%5Eresultado_u_situacao%3D7%5Eresultado_u_uf_gravameCONTAINSMG%5Eresultado_u_data_notificacaoBETWEENjavascript%3Ags.beginningOfLastMonth%28%29%40javascript%3Ags.endOfToday%28%29%5EORDERBYresultado_u_data_liberacao&sysparm_record_rows=1994" class="btn btn-icon table-btn-lg icon-info list_popup" data-type="list2_popup" data-list_id="u_resultadochassi_case" style="margin-left:0px" title="" aria-label="Visualizar Registro: __ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=" data-use-href="true" data-popover-title="__ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=" data-popover-title-is-html="false" aria-haspop="true" role="button" aria-expanded="false" data-original-title="Visualização __ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE="></a></td><td class="vt" ng-non-bindable=""><a class="linked formlink" aria-label="Abrir Registro: __ENC__YjIyNzY4NjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5NTY=-MDBlNjIwNjhkYjE5YTc4NGNkM2QzMmZmYWE5NjE5MTE=" href="sn_customerservice_resultado_chassis.do?sys_id=00e62068db19a784cd3d32ffaa961911&sysparm_view=Ralatório&sysparm_record_target=u_resultadochassi_case&sysparm_record_row=1&sysparm_record_rows=1994&sysparm_record_list=resultado_u_processoISNOTEMPTY%5Eresultado_u_situacao%3D7%5Eresultado_u_uf_gravameCONTAINSMG%5Eresultado_u_data_notificacaoBETWEENjavascript%3Ags.beginningOfLastMonth%28%29%40javascript%3Ags.endOfToday%28%29%5EORDERBYresultado_u_data_liberacao">MG</a></td><td class="vt" ng-non-bindable=""><a class="linked formlink" aria-label="Abrir Registro: __ENC__YTYwZTBlOGZkYjMwNjcwNDcyYjQ3YTMwYmE5NjE5Mzg=-ODdkY2MyMGJkYjMwNjcwNDcyYjQ3YTMwYmE5NjE5ZjM=" href="task.do?sys_id=a60e0e8fdb30670472b47a30ba961938&sysparm_view=Ralatório&sysparm_record_target=u_resultadochassi_case&sysparm_record_row=49&sysparm_record_rows=1994&sysparm_record_list=resultado_u_processoISNOTEMPTY%5Eresultado_u_situacao%3D7%5Eresultado_u_uf_gravameCONTAINSMG%5Eresultado_u_data_notificacaoBETWEENjavascript%3Ags.beginningOfLastMonth%28%29%40javascript%3Ags.endOfToday%28%29%5EORDERBYresultado_u_data_liberacao">CS0391527</a></td><td class="vt" ng-non-bindable=""><div class="datex date-calendar" title="4 semanas atrás" timeago="2018-10-01 19:29:51" timeago-attrs="title" data-original-title="cerca de um mês atrás">01/10/2018 16:29:51</div><div class="datex date-calendar-short" title="4 semanas atrás" timeago="2018-10-01 19:29:51" timeago-attrs="title" data-original-title="cerca de um mês atrás">01/10 16:29</div><div class="datex date-timeago" title="01/10/2018 16:29:51" timeago="2018-10-01 19:29:51" data-original-title="01/10/2018 16:29:51" null="cerca de um mês atrás">cerca de um mês atrás</div></td><td class="vt" ng-non-bindable="">9C2MC35006R043929</td><td class="vt" ng-non-bindable="">HDY3415</td><td class="vt" ng-non-bindable="">2316/2018</td><td class="vt" ng-non-bindable="">00/00/0000 00:00:00</td><td class="vt" ng-non-bindable="">Baixa Realizada</td><td class="vt vt-spacer" style="padding: 0"></td></tr><tr id="row_u_resultadochassi_case___ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" class="list_row list_even list_row_compact" style="" sys_id="__ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" record_class="u_resultadochassi_case" collapsed="true" data-type="list2_row" data-list_id="u_resultadochassi_case"><td class="list_decoration_cell col-control col-small col-center " style="white-space:nowrap;" rowspan="1"><span class="input-group-checkbox"><input type="checkbox" title="Marcar registro para Ação de lista" id="check_u_resultadochassi_case___ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" name="check_u_resultadochassi_case" class="checkbox " data-type="list2_checkbox" data-list_id="u_resultadochassi_case" data-original-title="Marcar registro para Ação de lista"><label for="check_u_resultadochassi_case___ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" style="" class="checkbox-label"><span class="sr-only">Selecione o registro para ação: __ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=</span></label></span></td><td class="list_decoration_cell col-small col-center " rowspan="1"><a href="u_resultadochassi_case.do?sys_id=__ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=&sysparm_view=Ralatório&sysparm_record_target=u_resultadochassi_case&sysparm_record_row=50&sysparm_record_list=resultado_u_processoISNOTEMPTY%5Eresultado_u_situacao%3D7%5Eresultado_u_uf_gravameCONTAINSMG%5Eresultado_u_data_notificacaoBETWEENjavascript%3Ags.beginningOfLastMonth%28%29%40javascript%3Ags.endOfToday%28%29%5EORDERBYresultado_u_data_liberacao&sysparm_record_rows=1994" class="btn btn-icon table-btn-lg icon-info list_popup" data-type="list2_popup" data-list_id="u_resultadochassi_case" style="margin-left:0px" title="Visualização __ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" aria-label="Visualizar Registro: __ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" data-use-href="true" data-popover-title="__ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" data-popover-title-is-html="false" aria-haspop="true" role="button" aria-expanded="false" data-original-title="Visualização __ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI="></a></td><td class="vt" ng-non-bindable=""><a class="linked formlink" aria-label="Abrir Registro: __ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" href="sn_customerservice_resultado_chassis.do?sys_id=8ecfb999db89ef04cd3d32ffaa961952&sysparm_view=Ralatório&sysparm_record_target=u_resultadochassi_case&sysparm_record_row=50&sysparm_record_rows=1994&sysparm_record_list=resultado_u_processoISNOTEMPTY%5Eresultado_u_situacao%3D7%5Eresultado_u_uf_gravameCONTAINSMG%5Eresultado_u_data_notificacaoBETWEENjavascript%3Ags.beginningOfLastMonth%28%29%40javascript%3Ags.endOfToday%28%29%5EORDERBYresultado_u_data_liberacao">MG</a></td><td class="vt" ng-non-bindable=""><a class="linked formlink" aria-label="Abrir Registro: __ENC__YmVjMGMyNTFkYmMxMjc0NDcyYjQ3YTMwYmE5NjE5YmM=-OGVjZmI5OTlkYjg5ZWYwNGNkM2QzMmZmYWE5NjE5NTI=" href="task.do?sys_id=bec0c251dbc1274472b47a30ba9619bc&sysparm_view=Ralatório&sysparm_record_target=u_resultadochassi_case&sysparm_record_row=50&sysparm_record_rows=1994&sysparm_record_list=resultado_u_processoISNOTEMPTY%5Eresultado_u_situacao%3D7%5Eresultado_u_uf_gravameCONTAINSMG%5Eresultado_u_data_notificacaoBETWEENjavascript%3Ags.beginningOfLastMonth%28%29%40javascript%3Ags.endOfToday%28%29%5EORDERBYresultado_u_data_liberacao">CS0396337</a></td><td class="vt" ng-non-bindable=""><div class="datex date-calendar" title="3 semanas atrás" timeago="2018-10-08 19:44:07" timeago-attrs="title" data-original-title="28 dias atrás">08/10/2018 16:44:07</div><div class="datex date-calendar-short" title="3 semanas atrás" timeago="2018-10-08 19:44:07" timeago-attrs="title" data-original-title="28 dias atrás">08/10 16:44</div><div class="datex date-timeago" title="08/10/2018 16:44:07" timeago="2018-10-08 19:44:07" data-original-title="08/10/2018 16:44:07" null="28 dias atrás">28 dias atrás</div></td><td class="vt" ng-non-bindable="">9C2KC2500HR028271</td><td class="vt" ng-non-bindable="">PZA6261</td><td class="vt" ng-non-bindable="">2479/2018</td><td class="vt" ng-non-bindable="">00/00/0000 00:00:00</td><td class="vt" ng-non-bindable="">Baixa Realizada</td><td class="vt vt-spacer" style="padding: 0"></td></tr></tbody>
答案 0 :(得分:0)
解决方案是将驱动程序的焦点更改为网格所在的框架:
driver0.switchTo().frame("gsft_main");
WebElement PaginasGrid = driver0.findElement(By.id("list_nav_u_resultadochassi_case"));
System.out.println(totPaginas.getText());