我已經寫了一個文件,其中包含許多我希望用於各種E2E測試的函數。我一直在試圖測試,並找到了一些解決方案,但沒有爲我工作。在量角器中從一個文件讀到另一個文件JS
這是事情的立場。
在我TestingFunc.js文件我已經創建了以下內容:
var TestingFunc = function() {
this.login = function(Url) {
browser.ignoreSynchronization = true;
browser.get(Url);
browser.wait(EC.elementToBeClickable(element(by.eeHook('login',null,null))), 300000);
element(by.eeHook('login', null, null)).click();
element(by.eeHook('authenticationEmailField',null,null)).sendKeys(logins.International);
element(by.name('password')).sendKeys(logins.password);
element(by.eeHook('authenticationLoginButton',null,null)).click();
browser.wait(EC.elementToBeClickable(paymentFlow), 100000);
paymentFlow.click();
browser.wait(EC.elementToBeClickable(depositAmount), 7000);
};
};
,我試圖在下面來閱讀:
var url = 'http://master.mrgreen.avengers.zone/en-US/casino';
var TestingFunc = require("C:/Users/davbor.3DB/MrGreen Google Drive/LetsTest/TestingFunc.js");
describe("The security application", function() {
var test = new TestingFunc();
it("will login to the page", function() {
test.login(url);
});
});
但每次我運行它的時候我不斷收到錯誤:
Failures:
1) The security application encountered a declaration exception
Message:
TypeError: TestingFunc is not a constructor
Stack:
TypeError: TestingFunc is not a constructor
at Suite.<anonymous> (C:\Users\davbor.3DB\MrGreen Google Drive\LetsTest\Testing.js:6:17)
不知道我很想念我甚至要求在房子開發商來看待它沒有成功。
你導出了你的'TestingFunc'嗎? 'module.exports = TestingFunc' – casraf
是啊,它已經寫出口,而不是出口,現在它看起來工作得很好,謝謝你的幫助:) –