[英]Want a redirection for a specific URl. so logged out users cannot be access the page directly. i amm working in codeigniter
[英]why do i get kicked out of a logged in web session?
所以我仍然有同样的问题,但是这次,我的代码不是问题,至少我认为是这样
我的代码:
import * as LogConst from 'C:\\Users\\Kristi\\Desktop\\BATests\\tests\\cypress\\fixtures\\Login_Data.json'
describe('all testcases hopefully', function () {
before(function () {
cy.clearLocalStorage();
cy.clearCookies();
});
it('loading', function () {
cy.visit('https://' + LogConst.server.name + ':' + LogConst.server.password + '@dev.capitalpioneers.de/');
cy.request({
method: 'POST',
url: '/login', // baseUrl is prepended to url
form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
body: {
username: 'LogConst.TestUserCostumer.usercos',
password: 'LogConst.TestUserCostumer.usercospass'
}
});
// just to prove we have a session
cy.getCookies('cypress-session-cookie').should('exist')
cy.contains('Login').click();
});
it('gets to products', function () {
cy.request('/produkte');
cy.getCookies('cypress-session-cookie').should('exist');
cy.contains('Produkt').click();
cy.url()
.should('include', '/produkte');
});
it('selects Dr. Peters ', function () {
cy.request('/produkt/hotelimmobilie-aachen/');
cy.getCookies('cypress-session-cookie').should('exist');
cy.contains('Dr. Peters').click();
cy.get('#sum_slider[type=range]')
.invoke('val', 50000)
.trigger('change')
});
it('downloads all files and checks the checkboxes', function () {
cy.get('#ga-btn-invest-now-product-detail-hotelimmobilie-aachen').click();
cy.contains('Fondsprospekt').click();
cy.contains('Wesentlichen Anlegerinformationen').click();
cy.get('#pre_check_inGermany').click({force: true});
cy.get('#pre_check_readDocument1').click({force: true});
cy.get('#pre_check_readDocument2').click({force: true});
// cy.pause();
cy.get('.button.button.button--full-width.button--yellow.js-outbrain-invest[type=submit]').click();
});
单击最后一个按钮后,我被踢出并重定向到登录页面,而不是转到下一个应具有此URL的页面:
https://dev.capitalpioneers.de/investor/investment/ 动态变化的数字 / investieren /
问题是什么? 我没有收到任何错误消息
这是赛普拉斯的预期行为。 我相信您必须在每个it()
/ context()
保留cookie,
beforeEach('Preserve the cookies to persist the state', () => { Cypress.Cookies.preserveOnce('sessionid', 'csrftoken') })
在上面的脚本中, sessionid
和csrftoken
是我希望在每次测试后保留/保留的令牌名称。
另一种方法是将要保留的Cookie令牌列入白名单,
Cypress.Cookies.defaults({whitelist: 'sessionid'});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.