0
ブラウザコンソールからapiを使用してログインする方法があります。失敗:不明なエラー:分度器のbrowser.executeScript()の後にブラウザが定義されていません
this.logInViaAPI = function (user) {
browser.executeScript(function (user) {
var xhr = new XMLHttpRequest();
xhr.open("POST", '/api/v1/....', true);
xhr.setRequestHeader('token', browser.params.tokens.token);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send('{"email": "' + user.login + '", "password": "' + user.apipassword + '"}');
});
};
やテスト
beforeAll(function() {
browser.get("");
});
it("test", function(){
helpers.logInViaAPI(browser.params.regularUser);
browser.refresh();
});
でそれを使用して、私は次のエラーを取得します。私は別のことをしなければならないかもしれませんが、アイデアはありません。
*- Failed: unknown error: browser is not defined
(Session info: chrome=53.0.2785.143)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 10.0 x86_64)
(Session info: chrome=53.0.2785.143)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 10.0 x86_64)
at new bot.Error (\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
at Object.bot.response.checkResponse (\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
at \node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
at [object Object].promise.Promise.goog.defineClass.invokeCallback_ (/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14)
at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
at goog.async.run.processWorkQueue (\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
at process._tickCallback (node.js:368:9)
From: Task: Run it("test") in control flow
at [object Object].promise.Promise.goog.defineClass.invokeCallback_ (/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14)
at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
at goog.async.run.processWorkQueue (\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
From asynchronous test:
Error
at Suite.<anonymous> (\test\e2e\specs\search\search.loggedIn.spec.js:86:5)
at Object.<anonymous> (\test\e2e\specs\search\search.loggedIn.spec.js:8:1)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)*