赛普拉斯:如何在赛普拉斯中访问 wp-admin?
Cypress: How to access wp-admin in cypress?
这里有人在 wp-admin 中自动化 Wordpress 吗?我一直收到错误
错误:您的浏览器阻止或不支持 Cookie。您必须启用 cookie 才能使用 WordPress。
我试过这段代码,但我在登录时遇到了同样的错误。我无法访问仪表板
beforeEach('Setcookies', () => {
Cypress.Cookies.preserveOnce('wordpress_{hash}','wordpress_logged_in_[hash]')
})
我在仪表板中做了一些自动化,并通过使用 Cypress.Cookies.defaults()
方法的 regex powers 使事情正常进行。
所以我的测试看起来像:
context('Test Dashboard', () => {
before(() => {
// This is a custom command that logs in a user for me
cy.loginAs('user')
/**
* This is responsible for keeping the user logged in
* throughout the test
*/
Cypress.Cookies.defaults({
preserve: /wordpress_|wordpress_logged_in_/,
})
})
it('loads the Dashboard', () => {
cy.visit('/wp-admin');
cy.get('h1').contains('Dashboard');
})
})
这里有人在 wp-admin 中自动化 Wordpress 吗?我一直收到错误
错误:您的浏览器阻止或不支持 Cookie。您必须启用 cookie 才能使用 WordPress。
我试过这段代码,但我在登录时遇到了同样的错误。我无法访问仪表板
beforeEach('Setcookies', () => {
Cypress.Cookies.preserveOnce('wordpress_{hash}','wordpress_logged_in_[hash]')
})
我在仪表板中做了一些自动化,并通过使用 Cypress.Cookies.defaults()
方法的 regex powers 使事情正常进行。
所以我的测试看起来像:
context('Test Dashboard', () => {
before(() => {
// This is a custom command that logs in a user for me
cy.loginAs('user')
/**
* This is responsible for keeping the user logged in
* throughout the test
*/
Cypress.Cookies.defaults({
preserve: /wordpress_|wordpress_logged_in_/,
})
})
it('loads the Dashboard', () => {
cy.visit('/wp-admin');
cy.get('h1').contains('Dashboard');
})
})