English 中文(简体)
Cypress - jQuery
  • 时间:2024-03-24 11:05:10

Cypress - jQuery

Previous Page Next Page  

风暴可以在其内部指挥下对 j子及其方法采取行动。 虽然Cypress利用这种方法确定一个网络要素,但JQuery为此目的使用了()美元的方法。

在Cypress,确定网络要素的指挥如下:


cy.get( h1#heading )

而如果是 j,则确定网络要素的指挥如下:


$( h1#heading )

飓风以 Java为基础,Script本具有不同步的性质。 然而,热带风暴指挥部通过在内部解决 Pro声而have然地行事,而后者从终端用户那里隐蔽。

然而,当Cypress对j Query物体及其方法采取行动时,必须具体实施Promise逻辑,使流量同步(在方法的帮助下)。

例如,虽然我们想摘录一个网络要素(用jQuery方法——案文)的内容,但我们要求采用当时的方法执行《意见》。

Promise Implementation in jQuery

以下是在酒吧执行红丝虫的指挥系统。


// 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")
      // Promise implementation with then()
      cy.get( h1#headingText ).find( span ).then(function(e){
         //method text to obtain text content
         const t = e.text()
         expect(t).to.contains( Sign )
      })
   })
})

在Kj Query,如果提供的定位器与OMS的任何网络元素不匹配,则将进行空洞收集。

为了避免出现例外情况,建议核实酒类的收集时间长度为(a)美元。 指挥部门如下:


const e = $( #txt )
if (e.length > 0){
   //proceed
}

然而,如下文所示,如果在OMM没有相应的网络要素,那么“Cypress”就自动进入回轨模式,直到具备这一要素或有时间外出。


cy.get( #txt )
   .then((e) => { //proceed working on element })

这种方法产生了灵敏。 此外,只有在网站内容与定位器相匹配的情况下,才能解决投标问题。 如果诉讼处于拒绝状态,则从不执行那部分的逻辑。

我们可以在Cypress获得 j,表达如下:


Cypress.$(  #txt ), where #txt is the locator.

Implementation of jQuery methods

下面是发现和实施“ j”气旋风暴试验的指令。


// 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")
      // access web element with Cypress.$
      cy.request( / ).get( h1#headingText ).then(function(e){
         Cypress.$(e).find( span )
         const t = e.text()
         cy.log(t)
      })
   })
})

随着上述测试的进行,如果我们打开了哥索尔(压缩F12),并找到必要的网络要素,加上“Cypress.$”(h1#headingText ).text(),我们可以核实我们的测试,如下所示:

Implementation of jQuery Methods

日志信息——信号——来自Cypress的cy。

Advertisements