我目前正在尝试第一次使用 Cypress,并在某个测试期间关闭 cypress uncaught:Exception,但我想在测试完成后将其打开。我怎样才能做到这一点 ?谢谢
PS:我这样禁用它`
cy.on('uncaught:exception', () => false);
Run Code Online (Sandbox Code Playgroud) javascript uncaught-exception cypress cypress-cucumber-preprocessor
我正在开发这个模板,其中使用 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) 我是 cypress 的新手,正在尝试在 POM 上创建框架。
我已按照以下步骤创建框架
{
"RxClaims_LoginPage":
{
"UserName":"#f0",
"Password":"#f1",
"SignInButton":"#xlg0003"
}
}
Run Code Online (Sandbox Code Playgroud)
/// <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) 示例代码-
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。
cypress ×3
javascript ×2
cypress-cucumber-preprocessor ×1
pageobjects ×1
playwright ×1
typescript ×1
url ×1