Я создаю свою первую платформу транспортира и пытаюсь выполнить пробный тест локально в рамках моего проекта. Я могу обновить и запустить веб-драйвер в порядке. Никаких проблем. Супер запутался, где я ошибся!
Я добрался до уровня проекта и выполнил команду
npm run protractor
Я получил следующее сообщение от моего терминала Mac
Jacquelines-MacBook-Air:JSworkspace jacquelinegeorge$ cd LocatorTraining
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$ npm run protractor
> LocatorTraining@ protractor /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining
> protractor configurations.js
[11:12:24] I/launcher - Running 1 instances of WebDriver
[11:12:24] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
F
Failures:
1) protractor page Object training encountered a declaration exception
Message:
ReferenceError: datadrive is not defined
Stack:
ReferenceError: datadrive is not defined
at Object.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/data.js:10:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Suite.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:3:9)
Message:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
Stack:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.manage().window().maximize()
at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:10:37)
at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
1 spec, 1 failure
Finished in 0.136 seconds
[11:12:27] I/launcher - 0 instance(s) of WebDriver still running
[11:12:27] I/launcher - chrome #01 failed 1 test(s)
[11:12:27] I/launcher - overall: 1 failed spec(s)
[11:12:27] E/launcher - Process exited with error code 1
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining@ protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining@ protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
Итак, я проверил файл configurations.js, который выглядит так (это правильный файл Spec.js, который я тестирую):
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['PageObjectLocator1.js'],
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
browser.driver.manage().window().maximize();
//logs
//command for non angular web site
//reporting
//site Url???
}
}
Затем я перешел на запуск конфигурации и cli.js в проекте
поэтому я проверил свой Spec файл, у меня не было ошибок.
describe('protractor page Object training',function(){
var obj= require("./PageObjectDemo.js");
var d= require("./data.js");
beforeEach(function() {
obj.geturl();//the url on your test page is a method
});
it('Perform Simple Calculation ',function(){
// write your code here!!!
obj.firstnumber.sendKeys(d.datadrive.firstinput);//page of object properties
obj.secondnumber.sendKeys(d.datadrive.secondinput);//page object properties
obj.gobutton.click();
//Jasmine Attribute Syntax toBe. Jasmine takes care of the promise 'resolve'internally
expect(obj.result.getText()).toBe(d.datadrive.result);
//this confirm printout in console.
obj.result.getText().then(function(text){
console.log(text)
}) //end of console log message
})//end of it block
afterEach(function () {
console.log("If you can see this, test is completed. Well Done!!");
});
Итак, я проверил файл спецификации данных:
module.exports.datadrive=
{
firstinput:"3",
secondinput:"5",
result: "8"
}
console.log(datadrive.result);
Следуя совету Юна, я обновился до:
exports.datadrive = {
firstinput:"3",
secondinput:"5",
result: "8"
}
Получил следующий результат:
[17:16:06] I/launcher - 0 instance(s) of WebDriver still running
[17:16:06] I/launcher - chrome #01 failed 1 test(s)
[17:16:06] I/launcher - overall: 1 failed spec(s)
[17:16:06] E/launcher - Process exited with error code 1
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining@ protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining@ protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
ОК, в субботу я обновил свой node.js (установил обновленный node.js глобально, однако я запускаю свой npm run protractor
на локальном уровне проекта. Что-то не так сделал?) И снова запустил файл Spec. Получил следующее сообщение (вздох). Я действительно не знаю, что я сделал не так. Я совершенно сбит с толку.
Failures:
1) protractor page Object training Perform Simple Calculation
Message:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
Stack:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.manage().window().maximize()
at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:10:37)
at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
Message:
Failed: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
Stack:
Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at runWaitForAngularScript.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/browser.js:463:23)
at ManagedPromise.invokeCallback_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:103:7)Error
at ElementArrayFinder.applyAction_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:459:27)
at ElementArrayFinder.(anonymous function) [as sendKeys] (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:91:29)
at ElementFinder.(anonymous function) [as sendKeys] (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:831:22)
at UserContext.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:14:19)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:112:25
at new ManagedPromise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:1077:7)
at ControlFlow.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:2505:12)
at schedulerExecute (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:95:18)
at TaskQueue.execute_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3067:27)
From: Task: Run it("Perform Simple Calculation ") in control flow
at UserContext.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:94:19)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
From asynchronous test:
Error
at Suite.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:11:2)
at Object.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:1:63)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
1 spec, 1 failure
Finished in 0.186 seconds
[12:40:08] I/launcher - 0 instance(s) of WebDriver still running
[12:40:08] I/launcher - chrome #01 failed 1 test(s)
[12:40:08] I/launcher - overall: 1 failed spec(s)
[12:40:08] E/launcher - Process exited with error code 1
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining@ protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining@ protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$