带有辣椒的地图元素

发布于 2025-02-09 09:13:24 字数 6614 浏览 0 评论 0原文

我必须进行测试的朋友来验证我无法映射的元素中的文本。我已经尝试了一切! 工具提示,

该元素是我用XPath进行映射的

但这太可怕了!!!我需要在状态列中验证单元格每个元素的工具提示的所有文本。是否有一种更简单的方法来执行此操作并映射元素而不使用XPath

[![element :txt_tooltip, :xpath, '/html/body/div\[2\]/div/div\[2\]/table/tbody/tr\[3\]/td\[1\]/div/div\[2\]/div\[1\]/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr\[2\]/td\[2\]/table/tbody/tr\[2\]/td/table/tbody/tr\[2\]/td/table/tbody/tr/td/div/div\[2\]/div/div/div/table/tbody/tr\[3\]/td\[6\]/img'

get_text_tooltip = txt_tooltip.text
expect(get_text_tooltip).eq ('Somente Leitura')



-Formatted HTML-
 
<a name="TVXWFMTGINSTATOCE"></a>
<div class="tvCaption">
   <div style="display:inline-block;width:100%">
      <img src="r/std/static/pixel.gif" class="icon Enabled icon_grid" draggable="false" onclick="sendEvent(0,event,this,true,0,'','1bfd','ControlMenu#','','','','','');"><img src="r/std/static/pixel.gif" class="icon Enabled icon_norows" draggable="false" onclick="sendEvent(0,event,this,searchImage(this),0,'','1bfd','SelectNone#','','','','','');" alt="Selecionar Nenhum" tooltip="Selecionar Nenhum"><img src="r/std/static/pixel.gif" class="icon Enabled icon_allrows" draggable="false" onclick="sendEvent(0,event,this,searchImage(this),0,'','1bfd','SelectAll#','','','','','');" alt="Selecionar todos" tooltip="Selecionar todos">&nbsp;Lista campos
      <div onclick="if(notSelecting()) sendEvent(0,event,this,searchImage(this),0,'','1bfd','TMMenu#','','','','','');" style="white-space: nowrap;" class="tvMsg tvMsgEna"><img src="r/std/icons/menu64.png" class="icon" draggable="false"></div>
      <div onclick="if(notSelecting()) sendEvent(0,event,this,searchImage(this),0,'','1bfd','CambioLabel#','','','','','');" class="tvMsg tvMsgEna" style="white-space: nowrap;" tooltip="Editar Label">
         <img src="r/std/static/label16.gif" class="icon" draggable="false">
         <div class="tvCaptionSep"></div>
      </div>
   </div>
</div>
<div>
   <div style="" class="tvContent">
      <div style="display:table;width:100%; background:inherit;">
         <div style="display:table-cell;">
            <table class="tvGrid" width="100%">
               <tbody>
                  <tr>
                     <th colspan="1" class="tvHeader">Nome</th>
                     <th colspan="1" class="tvHeader">Etiqueta</th>
                     <th colspan="1" class="tvHeader">Tipo Dado</th>
                     <th colspan="1" class="tvHeader">Valores </th>
                     <th colspan="1" class="tvHeader" width="1">Preenchimento automático</th>
                     <th colspan="1" class="tvHeader">Status </th>
                     <th colspan="1"></th>
                  </tr>
                  <tr oncontextmenu="if(!this.cancelEvent) {sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','BtnDropDownRow#',0,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','Select#',0,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                     <td class="tvCell" valign="center" align="left">FLAG_INSERIMENTO_LETTURA_E</td>
                     <td class="tvCell" valign="center" align="left"> Leitura Existente</td>
                     <td class="tvCell" valign="center" nowrap="" align="left"></td>
                     <td class="tvCell" valign="center" align="left"></td>
                     <td class="tvCell" tooltip="" width="1" valign="center" align="left"></td>
                     <td class="tvCell" valign="center" align="center"><img tooltip="Facultativo" src="r/std/static/ok16.gif"></td>
                     <td style="line-height:1px;padding:0px;" class="tvCell" width="30" valign="center" align="center">
                        <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1bfd','BtnDropDownRow#',0,'','','','');" class="but">
                           <div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>
                        </div>
                     </td>
                  </tr>
                  <tr oncontextmenu="if(!this.cancelEvent) {sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','BtnDropDownRow#',1,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','Select#',1,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll tvRowSelected" style="cursor:pointer;">
                     <td class="tvCell" valign="center" align="left">XWFMSLETMATRICOLA_E</td>
                     <td class="tvCell" valign="center" align="left"> Nº Hidrômetro</td>
                     <td class="tvCell" valign="center" nowrap="" align="left"></td>
                     <td class="tvCell" valign="center" align="left"></td>
                     <td class="tvCell" tooltip="[AIMPMATRICOLA]" width="1" valign="center" align="left">
                        <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1bfd','AUTOFILLBTN#',1,'','','','');" class="but butAct" tabindex="0" tooltip="Preenchimento automático ativado" type="BUTTON">
                           <div><img src="r/std/icons/checkboxselected64.png" class="icon" draggable="false" align="absmiddle"></div>
                        </button>
                     </td>
                     <td class="tvCell" valign="center" align="center"><img tooltip="Somente Leitura" src="r/std/static/lock16.gif"></td>
                     <td style="line-height:1px;padding:0px;" class="tvCell" width="30" valign="center" align="center">
                        <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1bfd','BtnDropDownRow#',1,'','','','');" class="but">
                           <div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>
                        </div>
                     </td>
                  </tr>

Friends I have to do a test to validate the text inside an element that I am not able to map. I've tried everything!! The element is a tooltip

I did the mapping by xpath but it's horrible!!!

I need to validate all the text of the tooltips of each element of the cell in the status column. Is there an easier way to do this and map the element without using xpath

[![element :txt_tooltip, :xpath, '/html/body/div\[2\]/div/div\[2\]/table/tbody/tr\[3\]/td\[1\]/div/div\[2\]/div\[1\]/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr\[2\]/td\[2\]/table/tbody/tr\[2\]/td/table/tbody/tr\[2\]/td/table/tbody/tr/td/div/div\[2\]/div/div/div/table/tbody/tr\[3\]/td\[6\]/img'

get_text_tooltip = txt_tooltip.text
expect(get_text_tooltip).eq ('Somente Leitura')



-Formatted HTML-
 
<a name="TVXWFMTGINSTATOCE"></a>
<div class="tvCaption">
   <div style="display:inline-block;width:100%">
      <img src="r/std/static/pixel.gif" class="icon Enabled icon_grid" draggable="false" onclick="sendEvent(0,event,this,true,0,'','1bfd','ControlMenu#','','','','','');"><img src="r/std/static/pixel.gif" class="icon Enabled icon_norows" draggable="false" onclick="sendEvent(0,event,this,searchImage(this),0,'','1bfd','SelectNone#','','','','','');" alt="Selecionar Nenhum" tooltip="Selecionar Nenhum"><img src="r/std/static/pixel.gif" class="icon Enabled icon_allrows" draggable="false" onclick="sendEvent(0,event,this,searchImage(this),0,'','1bfd','SelectAll#','','','','','');" alt="Selecionar todos" tooltip="Selecionar todos"> Lista campos
      <div onclick="if(notSelecting()) sendEvent(0,event,this,searchImage(this),0,'','1bfd','TMMenu#','','','','','');" style="white-space: nowrap;" class="tvMsg tvMsgEna"><img src="r/std/icons/menu64.png" class="icon" draggable="false"></div>
      <div onclick="if(notSelecting()) sendEvent(0,event,this,searchImage(this),0,'','1bfd','CambioLabel#','','','','','');" class="tvMsg tvMsgEna" style="white-space: nowrap;" tooltip="Editar Label">
         <img src="r/std/static/label16.gif" class="icon" draggable="false">
         <div class="tvCaptionSep"></div>
      </div>
   </div>
</div>
<div>
   <div style="" class="tvContent">
      <div style="display:table;width:100%; background:inherit;">
         <div style="display:table-cell;">
            <table class="tvGrid" width="100%">
               <tbody>
                  <tr>
                     <th colspan="1" class="tvHeader">Nome</th>
                     <th colspan="1" class="tvHeader">Etiqueta</th>
                     <th colspan="1" class="tvHeader">Tipo Dado</th>
                     <th colspan="1" class="tvHeader">Valores </th>
                     <th colspan="1" class="tvHeader" width="1">Preenchimento automático</th>
                     <th colspan="1" class="tvHeader">Status </th>
                     <th colspan="1"></th>
                  </tr>
                  <tr oncontextmenu="if(!this.cancelEvent) {sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','BtnDropDownRow#',0,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','Select#',0,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                     <td class="tvCell" valign="center" align="left">FLAG_INSERIMENTO_LETTURA_E</td>
                     <td class="tvCell" valign="center" align="left"> Leitura Existente</td>
                     <td class="tvCell" valign="center" nowrap="" align="left"></td>
                     <td class="tvCell" valign="center" align="left"></td>
                     <td class="tvCell" tooltip="" width="1" valign="center" align="left"></td>
                     <td class="tvCell" valign="center" align="center"><img tooltip="Facultativo" src="r/std/static/ok16.gif"></td>
                     <td style="line-height:1px;padding:0px;" class="tvCell" width="30" valign="center" align="center">
                        <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1bfd','BtnDropDownRow#',0,'','','','');" class="but">
                           <div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>
                        </div>
                     </td>
                  </tr>
                  <tr oncontextmenu="if(!this.cancelEvent) {sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','BtnDropDownRow#',1,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1bfd','Select#',1,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll tvRowSelected" style="cursor:pointer;">
                     <td class="tvCell" valign="center" align="left">XWFMSLETMATRICOLA_E</td>
                     <td class="tvCell" valign="center" align="left"> Nº Hidrômetro</td>
                     <td class="tvCell" valign="center" nowrap="" align="left"></td>
                     <td class="tvCell" valign="center" align="left"></td>
                     <td class="tvCell" tooltip="[AIMPMATRICOLA]" width="1" valign="center" align="left">
                        <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1bfd','AUTOFILLBTN#',1,'','','','');" class="but butAct" tabindex="0" tooltip="Preenchimento automático ativado" type="BUTTON">
                           <div><img src="r/std/icons/checkboxselected64.png" class="icon" draggable="false" align="absmiddle"></div>
                        </button>
                     </td>
                     <td class="tvCell" valign="center" align="center"><img tooltip="Somente Leitura" src="r/std/static/lock16.gif"></td>
                     <td style="line-height:1px;padding:0px;" class="tvCell" width="30" valign="center" align="center">
                        <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1bfd','BtnDropDownRow#',1,'','','','');" class="but">
                           <div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>
                        </div>
                     </td>
                  </tr>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩动你心 2025-02-16 09:13:24

您一直在提出相同类型的问题,并且似乎并没有从答案中学到任何东西。您真的需要去学习CSS选择器并学习它们 - 尝试 https://flukeout.github.io/ 并进行处理,直到您了解所有选择器类型为止。

在这种情况下,您所显示的代码不能独自工作,因为您正在获得text当您需要的值实际上在tooltip元素的属性中。因此,要么您的代码不起作用,要么您首先移动鼠标,而HTML正在更改为显示为属于元素文本内容的事物。

使用CSS并获取您可以执行的所有元素的工具提示值,例如

all('tr.tvRow .tvCell:nth-child(6) img[tooltip]').map { |el| el['tooltip'] }

返回tooltip属性值的数组。从技术上讲,您可能会从此开始丢弃“ tr.tvrow”,但它仍然可以工作,但比后悔更好。您可以在SitePrism的“元素”语句中使用CSS,但是直到您真正了解CSS Selectors SitePrism确实只是对事物添加了更多的困惑。

You keep asking the same type of question, and don't appear to be learning anything from the answers. You really need to just go study CSS selectors and learn them - try https://flukeout.github.io/ and work on it until you understand all the selector types.

In this case the code you've shown can't be working alone because you're getting text when the value you need is actually in the tooltip attribute of the element. So either your code doesn't work, or you're moving the mouse first and the HTML is changing to something that shows that attribute as the text content of an element.

to use CSS and get the tooltip value of all the elements you could do something like

all('tr.tvRow .tvCell:nth-child(6) img[tooltip]').map { |el| el['tooltip'] }

which would return an array of the tooltip attribute values of the elements. Technically you could probably drop the 'tr.tvRow' from the beginning of that and it would still work but better safe than sorry. You could use that CSS in a SitePrism 'elements' statement, but until you really understand CSS selectors SitePrism is really just adding more confusion to things.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文