![](/img/trans.png)
[英]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.