小编Ros*_*ams的帖子

开启cypress uncaught:关闭后异常

我目前正在尝试第一次使用 Cypress,并在某个测试期间关闭 cypress uncaught:Exception,但我想在测试完成后将其打开。我怎样才能做到这一点 ?谢谢

PS:我这样禁用它`

cy.on('uncaught:exception', () => false);
Run Code Online (Sandbox Code Playgroud)

javascript uncaught-exception cypress cypress-cucumber-preprocessor

3
推荐指数
1
解决办法
237
查看次数

剧作家试拖

我正在开发这个模板,其中使用 DragTo() 函数进行拖放。当我在头部模式下运行测试时,它工作得很好。但是当我在无头模式下运行测试时,它根本不会拖动任何东西,并且测试将在页面空白的情况下通过。有什么方法可以减慢拖动速度,以便页面可以在跳转到其他操作之前识别拖动的元素?

我尝试通过以下方式添加超时但仍然没有运气:

await this.page.locator('text=Column').first()
  .dragTo(this.page.locator('[role="tabpanel"]')
  .first(), {force:true}), {timeout:3000};
Run Code Online (Sandbox Code Playgroud)

typescript playwright playwright-test

2
推荐指数
1
解决办法
3152
查看次数

赛普拉斯 POM 方法 | 如何在 Cypress 中读取 POM_Page.js 文件中的灯具数据

我是 cypress 的新手,正在尝试在 POM 上创建框架。

我已按照以下步骤创建框架

  1. 使用名为“locators.json”的文件创建了对象存储库,该文件中的数据如下所示
{
    "RxClaims_LoginPage":
    {
        "UserName":"#f0",
        "Password":"#f1",
        "SignInButton":"#xlg0003"
    }
}
Run Code Online (Sandbox Code Playgroud)
  1. 在 Integration>Examples 下,我创建了名为OR_Approch.js的测试,它看起来像
/// <reference types="Cypress" />

import ORLoginPage from '../PageObjects/OR_Login'

describe('OR_Approach',function(){

    it('RxClaimsLogin', function()  {
        const login = new ORLoginPage();
        cy.visit('/')
        cy.wait(2000)
        login.EnterData_In_UserName()
        login.Password()
        login.SignInButton()
      })

})
Run Code Online (Sandbox Code Playgroud)

3.我在 Integration>POM 下创建了另一个文件夹,其中包含所有 POM - 其中一个名为OR_Login.js看起来像

class ORLoginPage{


    EnterData_In_UserName()
    {
        cy.fixture('example').then(function (dataJson) {
            this.testData = dataJson;
        })
        cy.fixture('locators').then(function (oRdata) {
            this.objRep = oRdata;
        })  
        cy.enterDatainTextBox(this.objRep.RxClaims_LoginPage.UserName,this.testData.UserName)
        return this
    }  
    Password(){
        return 'cy.enterDatainTextBox(this.objRep.RxClaims_LoginPage.Password,this.testData.Password)'
    }
    SignInButton(){ …
Run Code Online (Sandbox Code Playgroud)

javascript pageobjects cypress

0
推荐指数
1
解决办法
980
查看次数

无法验证 cy.url().should('be.equal', '&lt;givenURL&gt;');

示例代码-

describe('My Second Test Suite', function() {
it('My FirstTest case',function() {
 cy.visit('https://www.google.com')
 cy.url().should('be.equal', 'https://www.google.com');  
})
})
Run Code Online (Sandbox Code Playgroud)

错误-断言https://www.google.com/等于https://www.google.com AssertionError 4000 毫秒后重试超时:预期 'https://www.google.com/' 等于 'https:// /www.google.com'

我试图断言当前 url 等于给定 url。

url cypress

0
推荐指数
1
解决办法
237
查看次数