English 中文(简体)
Cypress - Text Verification
  • 时间:2024-03-24 11:08:21

Cypress - Text Verification

Previous Page Next Page  

方法案文可以用于获取网络内容。 此外,还可增加一些建议,以核查案文内容。

Implementation with text()

Given below is the command for the implementation with text() with regards to verification −


// test suite
describe( Tutorialspoint , function () {
   // it function to identify test
   it( Scenario 1 , function (){
      // test step to launch a URL
      cy.visit("https://accounts.google.com")
      // identify element
      cy.get( h1#headingText ).find( span ).then(function(e){
         //method text to obtain text content
         const t = e.text()
         expect(t).to.contains( Sign )
      })
   })
})

产出如下:

Implementation with Text()

产出记录显示用文字方法获得的文本标语。

Implementation with text assertions

我们还可以在以下指挥机构的帮助下,在网络要素文本上执行主张:


// test suite
describe( Tutorialspoint , function () {
   // it function to identify test
   it( Scenario 1 , function (){
      // test step to launch a URL
      cy.visit("https://accounts.google.com")
      // verify text with have.text
      cy.get( h1#headingText ).find( span ).should( have.text , Sign in )
   })
})

产出如下:

Implementation with Text Assertions

产出记录显示对案文的核查,应当加以说明。

Advertisements