柏树:可以';t在Cypress浏览器中登录

柏树:可以';t在Cypress浏览器中登录,cypress,Cypress,我正在尝试使用Cypress设置Vue应用程序的E2E测试 我可以使用常规的Chrome浏览器登录应用程序。但是,Chrome打开的浏览器不允许我登录。通过Cypress自动登录和手动登录都失败 有没有我错过的场景 我的Vue元素: <template> <div class="d-flex justify-content-center"> <div class="field is-horizontal">

我正在尝试使用Cypress设置Vue应用程序的E2E测试

我可以使用常规的Chrome浏览器登录应用程序。但是,Chrome打开的浏览器不允许我登录。通过Cypress自动登录和手动登录都失败

有没有我错过的场景

我的Vue元素:

<template>
    <div class="d-flex justify-content-center">

            <div class="field is-horizontal">
                <div class="field-label is-normal">
                    <label class="label">Username</label>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <input v-model="username" class="input" type="text"
                                   placeholder="Your username">
                        </div>
                    </div>
                </div>
            </div>
            <div class="field is-horizontal">
                <div class="field-label is-normal">
                    <label class="label">Password</label>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <input v-model="password" class="input" type="password"
                                   placeholder="Your password">
                        </div>
                    </div>
                </div>
            </div>
            <div class="field is-horizontal">
                <div class="field-label">
                    <!-- Left empty for spacing -->
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control text-center">
                            <button v-on:click="login()" class="button is-primary">
                                Login
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

更新:这里有一些建议:

在e2e测试运行期间,您看到了什么吗?就像柏树在那块地里打字一样


除了我不会使用非常通用的定位器之外,我会在
中停止。单击()
,然后在cypress.json中使用
cy.url()

检查新路径。您可以使用{…,“chromeWebSecurity”:false}来禁用交叉源errors@Boris你知道哪里出了问题吗?我也有类似的问题。在Cypress打开的Chrome浏览器中,我的一项功能甚至在手动操作时也表现得很怪异。然而,在普通的Chrome浏览器中,它可以正常工作perfect@Aish请参阅更新
describe('Logging in', () => {
    it('Logs in as admin', () => {
        cy.visit('/')
            .get('input[type="text"]')
            .type('Admin')
            .get('input[type="password"]')
            .type('Pass1234')
            .get('button').click()
            .location().should((loc) => {
            expect(loc.pathname).to.eq('/dashboard-main/dashboard');
        })
    })
})