从支持文件夹赛普拉斯加载功能

时间:2020-07-17 09:44:30

标签: cypress end-to-end

在我的支持文件夹中,我有一个名为action的文件夹。里面有一个名为login-action.js的文件。该文件中的代码如下所示:

class LoginActions{   
     login(usernameField, passwordField, username, password) {
        cy.get(usernameField).first().type(username);
        cy.get(passwordField).last().type(password);
     }
    }
    export default new LoginActions();

现在我想在测试中使用此登录功能

loginActions.login('[data-test=username]', '[data-test=password]', this.user.username, this.user.password);

这就是我在测试中称呼它的方式。但是,这不起作用。它说登录是未定义的。

1 个答案:

答案 0 :(得分:1)

我不认为您可以像这样做一样导出新对象,我通常只导出这样的类:

df=df.reset_index()
df['Date'] = df['Date'].where(df['Date'] != df['Date'].shift(), '')
df['ConstraintType'] = df['ConstraintType'].where(df['ConstraintType'] != df['ConstraintType'].shift(), '')
df = df.set_index(['Date', 'ConstraintType'])
df.to_excel(r'C:\Users\ram\Desktop\z1.xlsx', merge_cells=True)

您是否导入并创建新的对象loginAction像这样:

 export default LoginActions();

然后,您可以:

import LoginActions from '../../../support/pageObjects/{loginActionsPage}'
const loginActions = new LoginActions();