English 中文(简体)
Cypress - Web Tables
  • 时间:2024-03-24 10:05:43

Cypress - Web Tables

Previous Page Next Page  

风暴能够处理网页。 表格基本上分为两类:动态和静态。 固定表格的栏目和行数与动态表格不同。

在《html法典》中,表格以表格标语表示,而浏览则以斜线表示,栏目按斜线表示。

    为了进入各行,Cypress指挥系统如下:


 cy.get("tr")

    为进入各栏,Cypress指挥系统如下:


 cy.get("td") or cy.get("tr td")

    查阅一栏,特别安全局的表述如下:


td:nth-child(column number)

    To iterate through the rows/columns of the table, the Cypress command each is used.

在“旋风”中,我们有“指挥”next,排在紧接下。 这一指挥必须经过指挥。 突击队被用来转移到前面的兄弟姐妹。

下表的Html结构如下:

Html Structure

Example

让我们以表格为例,并核实第二栏(Open Source)中与价值 Sel相对应的内容,该栏是同OL联系的第一栏。

以下屏幕将登在你的电脑上:

Automation Tool

Implementation

下面是实施与表格有关的气旋风暴指挥系统:


describe( Tutorialspoint Test , function () {
   // test case
   it( Scenario 1 , function (){
      //URL launch
      cy.visit("https://sqengineer.com/practice-sites/practice-tables-selenium/")
      // identify first column
      cy.get( #table1> tbody > tr > td:nth-child(1) ).each(($elm, index, $pst)=> {
         // text captured from column1
         const t = $elm.text();
         // matching criteria
         if (t.includes( Selenium )){
            // next sibpng captured
            cy.get( #table1 > tbody > tr > td:nth-child(1) )
            .eq(index).next().then(function(d) {
               // text of following sibpng
               const r = d.text()
               //assertion
               expect(r).to.contains( Commercial );
            })
         }
      })
   });
});

产出如下:

Practice Tables

执行记录显示,第1栏所列数值为公开来源。 这是因为紧随同一行的Selenium(第一栏)的精干。

Advertisements