gpt4 book ai didi

javascript - 如何访问其他文件中的函数?

转载 作者:行者123 更新时间:2023-12-03 02:55:28 27 4
gpt4 key购买 nike

这会引发错误:“登录未定义”。

//<Common.js>
var Common = function(){
this.login = function(uname,password){
//All your code that you want to call from the test spec
element(by.id('txtUserName')).sendKeys(login);
element(by.id('txtPassword')).sendKeys(password);
element(by.xpath('//input[@id="btnLogin"]')).click();

};
};

module.exports = new Common();

//<Test.js>
var newPage = require('./Common.js');

describe('The application', function() {

it('should let you log into the application', function() {
newPage.login('abcd', '1234');
});
});


Failures:
1) The application should let you log into the application
Message:
Failed: login is not defined
Stack:
ReferenceError: login is not defined

最佳答案

将以下行中的“login”更新为“uname”

element(by.id('txtUserName')).sendKeys(uname);

关于javascript - 如何访问其他文件中的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47650251/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com