使用Ruby使用循环来验证Excel表线针对应用线

发布于 2025-02-12 04:07:23 字数 16093 浏览 0 评论 0原文

朋友,我会尽量详细。托马斯·沃尔波尔(Thomas Walpole)帮助我验证了工作表每行的信息是否与我应用程序网格的每一行相对应。但是,我想用来验证它,以使其更加美丽。我将如何更改下面的解决方案?

由于我不知道如何在这些条件下使用循环,因此我必须在工作表中的项目手工做,并一一验证

我的电子表格在前面的项目以下配置: |元素|状态| | NºHIDRômetro|Invisível| | Leitura |Invisível| | diâmetrodo HD |Invisível| | Filtro |Invisível| | padrãodeStalaçãoDoHD |Invisível| | Equipamento de Teletemetria acoplado |Invisível|

Spreadsheet.client_encoding = 'UTF-8'
  book = Spreadsheet.open('c:/temp/gab.xls', "r")
  sheet = book.worksheet 0
  #get the first row referring to the second column
  take_hidrometro_planilha = sheet.rows[1][1]

  pp "O item da planilha N. hidrometro esta configurado para  #{take_hidrometro_planilha}"
  expect(page).to have_css("tr.tvRow:nth-child(2) .tvCell:nth-child(6) img[tooltip='#{take_hidrometro_planilha}']")
  #takes the tooltip on the front according to the desired line and saves it in a variable
  take_hidrometro_front = find("tr.tvRow:nth-child(2) .tvCell:nth-child(6) img[tooltip]")[:tooltip]
  pp "O item do Front N. hidrometro esta configurado para  #{take_hidrometro_front}"
  #validates the worksheet variable with the variable captured on the front
  pp expect(take_hidrometro_front).to eql(take_hidrometro_planilha)

################## ######

<div style="" class="tvContent">
    <div style="display:table;width:100%; background:inherit;">
        <div style="display:table-cell;">
            <table width="100%" class="tvGrid">
                <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" width="1" class="tvHeader">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','1d13','BtnDropDownRow#',0,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',0,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">FLAG_INSERIMENTO_LETTURA_E</td>
                        <td valign="center" align="left" class="tvCell"> Leitura Existente</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip=""></td>
                        <td valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','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','1d13','BtnDropDownRow#',1,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',1,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETMATRICOLA_E</td>
                        <td valign="center" align="left" class="tvCell"> Nº Hidrômetro</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[AIMPMATRICOLA]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',1,'','','','');" 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','1d13','BtnDropDownRow#',2,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',2,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETLETTURA_E</td>
                        <td valign="center" align="left" class="tvCell"> Leitura</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip=""></td>
                        <td valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',2,'','','','');" 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','1d13','BtnDropDownRow#',3,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',3,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETID_XWFMTDCO_E</td>
                        <td valign="center" align="left" class="tvCell"> Diâmetro do HD</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XGABAIMPID_XWFMTDCO]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',3,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',3,'','','','');" 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','1d13','BtnDropDownRow#',4,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',4,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETSIGILLO_E</td>
                        <td valign="center" align="left" class="tvCell"> Filtro</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XWFMAIMPSIGILLO]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',4,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',4,'','','','');" 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','1d13','BtnDropDownRow#',5,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',5,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETID_XWFMTUBI_E</td>
                        <td valign="center" align="left" class="tvCell"> Padrão de instalação do HD</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XWFMAIMPID_XWFMTUBI]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',5,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',5,'','','','');" 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','1d13','BtnDropDownRow#',6,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',6,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XGABSLETTELCOUPEQUIP_E</td>
                        <td valign="center" align="left" class="tvCell"> Equipamento de telemetria acoplado</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XGABAIMPTELCOUPEQUIP]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',6,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',6,'','','','');" class="but">
                                <div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>

​png“ alt =”在此处输入图像说明”>

Friends, I'll try to be as detailed as possible. Thomas Walpole It helped me to validate if the information of each row of the worksheet corresponds to each row of the grid of my application. However I would like to use the for to validate this to make it more beautiful. How would I change the solution below?

As I don't know how to use the loop under these conditions, I'll have to do it by hand item by item in my worksheet and validate one by one with the items on the front

My spreadsheet is configured like this:
| Element | Status |
| Nº Hidrômetro |Invisível |
| Leitura |Invisível |
| Diâmetro do HD |Invisível |
| Filtro |Invisível |
| Padrão de instalação do HD |Invisível |
| Equipamento de telemetria acoplado |Invisível |

Spreadsheet.client_encoding = 'UTF-8'
  book = Spreadsheet.open('c:/temp/gab.xls', "r")
  sheet = book.worksheet 0
  #get the first row referring to the second column
  take_hidrometro_planilha = sheet.rows[1][1]

  pp "O item da planilha N. hidrometro esta configurado para  #{take_hidrometro_planilha}"
  expect(page).to have_css("tr.tvRow:nth-child(2) .tvCell:nth-child(6) img[tooltip='#{take_hidrometro_planilha}']")
  #takes the tooltip on the front according to the desired line and saves it in a variable
  take_hidrometro_front = find("tr.tvRow:nth-child(2) .tvCell:nth-child(6) img[tooltip]")[:tooltip]
  pp "O item do Front N. hidrometro esta configurado para  #{take_hidrometro_front}"
  #validates the worksheet variable with the variable captured on the front
  pp expect(take_hidrometro_front).to eql(take_hidrometro_planilha)

#################### HTML CODE ###################################

<div style="" class="tvContent">
    <div style="display:table;width:100%; background:inherit;">
        <div style="display:table-cell;">
            <table width="100%" class="tvGrid">
                <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" width="1" class="tvHeader">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','1d13','BtnDropDownRow#',0,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',0,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">FLAG_INSERIMENTO_LETTURA_E</td>
                        <td valign="center" align="left" class="tvCell"> Leitura Existente</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip=""></td>
                        <td valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','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','1d13','BtnDropDownRow#',1,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',1,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETMATRICOLA_E</td>
                        <td valign="center" align="left" class="tvCell"> Nº Hidrômetro</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[AIMPMATRICOLA]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',1,'','','','');" 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','1d13','BtnDropDownRow#',2,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',2,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETLETTURA_E</td>
                        <td valign="center" align="left" class="tvCell"> Leitura</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip=""></td>
                        <td valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',2,'','','','');" 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','1d13','BtnDropDownRow#',3,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',3,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETID_XWFMTDCO_E</td>
                        <td valign="center" align="left" class="tvCell"> Diâmetro do HD</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XGABAIMPID_XWFMTDCO]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',3,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',3,'','','','');" 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','1d13','BtnDropDownRow#',4,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',4,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETSIGILLO_E</td>
                        <td valign="center" align="left" class="tvCell"> Filtro</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XWFMAIMPSIGILLO]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',4,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',4,'','','','');" 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','1d13','BtnDropDownRow#',5,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',5,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XWFMSLETID_XWFMTUBI_E</td>
                        <td valign="center" align="left" class="tvCell"> Padrão de instalação do HD</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XWFMAIMPID_XWFMTUBI]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',5,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',5,'','','','');" 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','1d13','BtnDropDownRow#',6,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','1d13','Select#',6,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
                        <td valign="center" align="left" class="tvCell">XGABSLETTELCOUPEQUIP_E</td>
                        <td valign="center" align="left" class="tvCell"> Equipamento de telemetria acoplado</td>
                        <td align="left" class="tvCell" valign="center" nowrap=""></td>
                        <td valign="center" align="left" class="tvCell"></td>
                        <td align="left" width="1" class="tvCell" valign="center" tooltip="[XGABAIMPTELCOUPEQUIP]">
                            <button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','AUTOFILLBTN#',6,'','','','');" 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 valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
                        <td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
                            <div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','1d13','BtnDropDownRow#',6,'','','','');" class="but">
                                <div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>

enter image description here

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

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

发布评论

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

评论(1

过期情话 2025-02-19 04:07:23

假设您使用的是“电子表格”宝石 - 指南提供了您需要查看如何在此处使用循环的所有信息 -

sheet.each 1 do |row|
  expected_tooltip = row[1]
  expect(page).to have_css("tr.tvRow:nth-child .tvCell:nth-child(6) img[tooltip='#{expected_tooltip}']")
end

​在页面上。

如果您需要验证它们是特定顺序(为什么?),那么您可能需要类似的东西

xls_offset = 1
row_offset = 2
sheet.each_with_index(xls_offset) do |row, idx|
  expected_tooltip = row[1]
  expect(page).to have_css("tr.tvRow:nth-child(#{row_offset+idx}) .tvCell:nth-child(6) img[tooltip='#{expected_tooltip}']")
end

Assuming you're using the 'spreadsheet' gem - the guide provides all the info you need to see how to use a loop here - https://github.com/zdavatz/spreadsheet/blob/master/GUIDE.md

sheet.each 1 do |row|
  expected_tooltip = row[1]
  expect(page).to have_css("tr.tvRow:nth-child .tvCell:nth-child(6) img[tooltip='#{expected_tooltip}']")
end

That is all you need to do to verify all the tooltip texts in your spreadsheet exist on the page.

If you need to verify they are in a specific order (why?) then you'd probably need something like

xls_offset = 1
row_offset = 2
sheet.each_with_index(xls_offset) do |row, idx|
  expected_tooltip = row[1]
  expect(page).to have_css("tr.tvRow:nth-child(#{row_offset+idx}) .tvCell:nth-child(6) img[tooltip='#{expected_tooltip}']")
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文