diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..c50594231 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,52 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/node:8.11-browsers + environment: + # Fix issue with selenium-server in containers. + # See http://github.com/SeleniumHQ/docker-selenium/issues/87 + DBUS_SESSION_BUS_ADDRESS: /dev/null + steps: + - checkout + + - run: google-chrome --version + + - run: + name: NPM Install + command: | + npm i + cd testapp && npm i + + - save_cache: + key: node_modules-{{ .Branch }}-{{ checksum "package-lock.json" }} + paths: + - "node_modules" + - "testapp/node_modules" + + - run: + name: Lint + command: ./node_modules/.bin/gulp lint + + - run: + name: Selenium Start + background: true + command: | + ./node_modules/.bin/webdriver-manager update --versions.chrome=2.44 + ./node_modules/.bin/webdriver-manager start --versions.chrome=2.44 + + - run: + name: TestApp Start + background: true + command: | + npm start + + # Seems like the new circleci container no longer permits packet introspection on lo, even for root. + # - run: + # name: Extra tcp logging for BlockingProxy + # background: true + # command: sudo tcpdump -i lo 'tcp && dst localhost' -w $CIRCLE_ARTIFACTS/localdump.pcap + + - run: + name: Test + command: npm test diff --git a/.clang-format b/.clang-format index 70d6d17bc..8d1c3c310 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,3 @@ Language: JavaScript BasedOnStyle: Google -ColumnLimit: 80 +ColumnLimit: 100 diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE index e6b76b609..ff93cd582 100644 --- a/.github/ISSUE_TEMPLATE +++ b/.github/ISSUE_TEMPLATE @@ -6,7 +6,7 @@ To help us help you better, please do the following before submitting an issue: 1. Review the questions section of [CONTRIBUTING.md](https://github.com/angular/protractor/blob/master/CONTRIBUTING.md#contributing). 2. Make sure you are not asking a usage or debugging question. If you are, use [StackOverflow](http://stackoverflow.com/questions/tagged/protractor), [Google Group discussion list](https://groups.google.com/forum/?fromgroups#!forum/angular), or [Gitter](https://gitter.im/angular/protractor) to get help. -3. Provide a minimally reduced test case. This makes it much more likely that your bug will be fixed. +3. Provide a minimally reduced test case. This makes it much more likely that your bug will be fixed. Protractor has a test Angular application available at `http://www.protractortest.org/testapp` which you can use for the reproducible test case. 4. Fill in the information that corresponds to your type of issue below. 5. Delete this intro and any unrelated text :smile: (if you do not we'll assume you haven't read these instructions and automatically close the issue.) diff --git a/.gitignore b/.gitignore index ab25281a6..ed1a30d0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,21 @@ -built/ -node_modules/ -selenium/ -testapp/inbrowsertest/ -typings/ -website/bower_components/ -website/build/ -website/docgen/build/ +# Shared between .npmignore and .gitignore +yarn.lock chromedriver.log libpeerconnection.log xmloutput* npm-debug.log .idea/ - +.vscode/ +*.DS_Store *.swp +selenium/ + +# Build artifacts +built/ +spec/built/ +node_modules/ +website/bower_components/ +website/build/ +website/docgen/build/ diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index d87c2efaa..000000000 --- a/.jshintrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "unused": true, - "node": true, - "bitwise": true, - "immed": true, - "newcap": true, - "noarg": true, - "noempty": true, - "nonew": true, - "trailing": true, - "maxlen": 100, - "boss": true, - "eqnull": true, - "expr": true, - "laxbreak": true, - "loopfunc": true, - "sub": true, - "undef": true, - "quotmark": "single", - "evil": true, - "curly": true -} diff --git a/.npmignore b/.npmignore index 6a3bb6874..68655d6cd 100644 --- a/.npmignore +++ b/.npmignore @@ -1,22 +1,41 @@ +# Shared between .npmignore and .gitignore + +yarn.lock +chromedriver.log +libpeerconnection.log +xmloutput* +npm-debug.log +.idea/ +.vscode/ +*.DS_Store +*.swp +selenium/ + +# Development folders + +.github/ +built/spec/ +built/**/*.map debugging/ docs/ lib/ scripts/ spec/ stress/ -selenium/ testapp/ -typings/ website/ +exampleTypescript/*.js +exampleTypescript/node_modules/ +exampleTypescript/tmp/ +# Development files + +.clang-format .gitattributes -.github/ .gitignore .jshintrc .npmignore .travis.yml -chromedriver.log -libpeerconnection.log -npm-debug.log -xmloutput* +circle.yml +logo.svg release.md diff --git a/.travis.yml b/.travis.yml index b846414d2..a0bf19b20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js sudo: false node_js: - - "4" - - "6" + - "9" + - "10" env: global: @@ -24,9 +24,9 @@ matrix: - env: "JOB=bstack" exclude: - env: JOB=smoke - node_js: "6" + node_js: "9" - env: JOB=bstack - node_js: "6" + node_js: "9" addons: apt: @@ -36,13 +36,14 @@ addons: - g++-4.8 before_install: - - g++-4.8 --version + - travis_wait g++-4.8 --version before_script: - npm run install_testapp - npm run pretest - mkdir -p $LOGS_DIR - - ./scripts/travis_setup.sh + - scripts/travis_setup.sh + script: - ./scripts/testserver.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aeed7f96..9a7ef5972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,1156 @@ +# 6.0.0 + +Selenium 4 removes the control flow and most of these changes are based on those changes. To see the full list of changes, please refer to selenium-webdriver's [CHANGELOG](https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/CHANGES.md) + +## Breaking changes + +- Control flow is removed and you should use async await to run your tests. +- Other control flow related items: + - debugger, explore and element explorer have been removed + - jasminewd is no longer a dependency +- ignoreSynchronization has been deprecated and you should use `waitForAngularEnabled` +- Types for selenium-webdriver are currently in the types/ directory and are not complete. We are still missing some type definitions for selenium 4. +- Actions API in selenium-webdriver have changed and they will break your test. Also we have not exported it yet since the type definitions are not complete. + +## Features + +- ([cf43651](https://github.com/angular/protractor/commit/cf43651bd7719b2811225bd7aa084aca973df1c8)) + chore(debugprint): convert debugprint to TypeScript (#5074) + +- ([4672265](https://github.com/angular/protractor/commit/4672265773b415e80554f94bdcc9637340b70c25)) + chore(browser): remove timing issues with restart and fork (#5085) + + - remove .ready since forking should automatically return a browser + - getNewDriver should return a promised WebDriver that can be awaited + - fix interaction tests and local driver tests + - update unit tests for async await due to getNewDriver fix + closes #5031 +- ([b4dbcc2](https://github.com/angular/protractor/commit/b4dbcc2621e06fee9768b77d10ca3a3092b4d710)) + chore(elementexplorer): remove explorer bin file (#5094) + + closes #5092 + +- ([3b8f263](https://github.com/angular/protractor/commit/3b8f263d744a5e0f2e07abdeaf77ade24ec43ed1)) + chore(ignoreSynchornization): clean up to use waitForAngularEnabled (#5071) + + +- ([ffa3519](https://github.com/angular/protractor/commit/ffa35196751766028feb7cda38cf4d43ead2a6f7)) + chore(debugger): remove debugger and explore methods (#5070) + +- ([c9db3f3](https://github.com/angular/protractor/commit/c9db3f377c52a4cdd917c9b9d1e69808969ddf15)) + chore(promises): remove q promises and webdriver promises (#5052) + + - remove q promises and webdriver promises from the runner, launcher, plugins, and taskRunner + - add deprecated message to element explorer. + - add unhandledRejection + - update browser versions used in travis tests + +- ([e22065c](https://github.com/angular/protractor/commit/e22065ca6c91c6f49f9bbebcdc6351bdeb6e61ec)) + chore(promises): clean up driver providers and browser control flow (#5034) + + Driver providers and tests: + + - Use native promises over q promises in driver providers + - Remove driverProviderUseExistingWebDriver since the generation of the selenium server is already + accomplished when providing a selenium address in driverProvider.ts. Also clean up docs and tests. + + - Enabled the driverProviderLocal tests + - Clean up JSDocs for q.promise + Basic lib spec: + + - Remove auto unwrap test for a WebElement. Reference PR #3471 + Browser: + + - Remove control flow from waitForAngularEnabled, waitForAngular, and angularAppRoot in the + Browser class. + +## Dependencies + +- ([96ae17c](https://github.com/angular/protractor/commit/96ae17cdd8acf6cd388ddf691453fdbd7e7dd60e)) + deps(jasmine): upgrade jasmine 3.3 (#5102) + +- ([d213aa9](https://github.com/angular/protractor/commit/d213aa9aea2c10efb497202c6ec2aa98e416684c)) + deps(selenium): upgrade to selenium 4 (#5095) + + - elements workaround for WebElement.equals + - added a better unhandled rejection warning message in the launcher + control flow)bal function wrappers for mocha (these wrappers went away with + - fix the attach to session driver provider + Typing exported from Protractor: + + - removed ActionSequence and EventEmitter (actions is currently missing) + - removed promise.Promise + fulfilled, filter, whener, delayed, createFlow, controlFlow, all, + Typings exported from WebDriver: + + - removed attachToSession + - removed WebDriver instance methods: touchActions, call + - removed WebElement getSize and getLocation for getRect + - removed redefined global vars for testing + - In the typings, we are missing Options.setScriptTimeout method. This should not impact users + unless they are using the driver.manage() method. + Tests: + + - fix element equals test + - add missing 'await' in colorList test that is causing unhandled promise rejections. + - remove control flow related tests + - disable the install test. Installing from "file:../../" is not working. + - fix the attach to session driver provider test to exit with a 1 if errors are encountered + +- ([509f1b2](https://github.com/angular/protractor/commit/509f1b25762c850ba82bc7527684edc8d8b52275)) + deps(latest): upgrade to the gulp and typescript (#5089) + + * deps(latest): upgrade to the gulp and typescript + + - add in @types/loglevel and @types/yargs for webdriver-manager + - upgrade tslint clean up for tslint + supported by gulpp 4 and remove run sequence since this feature is + - remove compile to es5 + +- ([2def202](https://github.com/angular/protractor/commit/2def2026de4f68cd5264afca4aa4cb51a9b550a3)) + deps(webdriver-manager): use replacement (#5088) + + publish a beta release of use webdriver-manager-replacement until we + webdriver-manager + closes #5087 + +## Miscellaneous + +Minor fixes to remove the control flow completely and to prevent random execution order in Jasmine 3. + +- ([0a2809e](https://github.com/angular/protractor/commit/0a2809e62f34ed75632c80e1e792214e01eb0afe)) + chore(types): fix types to use not @types/selenium-webdriver (#5127) + + - Remove the USE_PROMISE_MANAGER test in spec/ts/basic + - Remove the check if we are using the control flow or not +- ([84cdc50](https://github.com/angular/protractor/commit/84cdc50771b23f840bf62cb33f742dff3aaff990)) + chore(jasmine): prevent random execution order in jasmine 3 (#5126) + + +# 5.4.2 + +## Features + +- ([db1b638](https://github.com/angular/protractor/commit/db1b6381d463c7cecf11dece2bf9412fecbd6f4d)) + feat(saucelabs): add sauceRegion support for eu datacenters (#5083) + + This change allows user to define the backend region from sauce via the `sauceRegion` property, + e.g. + + ```js + sauceUser: process.env.SAUCE_USERNAME, + sauceKey: process.env.SAUCE_ACCESS_KEY, + sauceRegion: 'eu', + ``` + Will run the test against `https://ondemand.eu-central-1.saucelabs.com:443/wd/hub/.` + + ```js + sauceUser: process.env.SAUCE_USERNAME, + sauceKey: process.env.SAUCE_ACCESS_KEY, + sauceRegion: 'us', + + // the default + sauceUser: process.env.SAUCE_USERNAME, + sauceKey: process.env.SAUCE_ACCESS_KEY, + ``` + Will run the test against https://ondemand.saucelabs.com:443/wd/hub/ + +## Fixes + +- ([f5dbe13](https://github.com/angular/protractor/commit/f5dbe13ad6755ae812627d8056527e351db8b34c)) + fix(deps): @types/node is now a dev dependency + +# 5.4.1 + +## Features + +- ([7b08083](https://github.com/angular/protractor/commit/7b0808396458fbc2bd46c7e929f4effecb2a3f1e)) + feat(driverProvider): Add useExistingWebDriver driver provider (#4756) + +- ([249e657](https://github.com/angular/protractor/commit/249e657baa605257c268f09078d56219776db9b1)) + feat(example): add examples of usage protractor framework with angular-material components; + (#4891) + +## Fixes + +- ([39485ca](https://github.com/angular/protractor/commit/39485ca49ad751814ae112b224ae054e697e102f)) + fix(typo): fixed typo in EC expectation alias (#4952) + +- ([07fefeb](https://github.com/angular/protractor/commit/07fefeb9636f8b3506df2eacbdb4ada29f50fbbd)) + fix(browser): browser.navigate() return type. (#4932) + + Changing return type of browser.navigate() to be Navigation instead of any. + +- ([0b1820c](https://github.com/angular/protractor/commit/0b1820c6c1d8b13e8fb2e64f27e4fe1d3cbcdd73)) + fix(package-lock.json): update package-lock.json to match package.json. (#4931) + +## Dependencies + +- ([2632bb6](https://github.com/angular/protractor/commit/2632bb67c3ac7773e8b769cd5c5ee5c6d7b69f3d)) + deps(webdriver_js_extender): update webdriver_js_extender to 2.1 (#4934) + +# 5.4.0 + +## Features + +- ([03e2209](https://github.com/angular/protractor/commit/03e22092557240217bbbcf641476db08cc35df77)) + feat(driverProvider) Adding browserstackProxy param in BrowserStack driverProvider (#4852) + +## Fixes + +- ([492230a](https://github.com/angular/protractor/commit/492230ab3445ca3aea3e60f55d27cb9825018ef9)) + fix(generate_doc.sh): Use ES6 lib to compile down to ES5 (#4884) + +- ([ed955e5](https://github.com/angular/protractor/commit/ed955e56a839d7f69da43acb6755763220d3681d)) + fix(travisCI): Update Node versions (#4847) + +- ([3702a70](https://github.com/angular/protractor/commit/3702a709fe251fed1de9ee1eab38593c2c371e94)) + fix(local): Ensure webdriver.gecko.driver path is passed to Selenium (#4502) + +- ([1c6a1a8](https://github.com/angular/protractor/commit/1c6a1a82f03f2bd5911dfc37f365329d6f5acb60)) + fix(circleci): Switch to using circleci v2 syntax and fix build errors (#4837) + +## Dependencies +- ([056eec2](https://github.com/angular/protractor/commit/056eec23a7d1534d5e8624d42a6c9d1f3106cf5d)) + deps(webdriver_js_extender): update webdriver_js_extender to 2.0 (#4882) + 1. update webdriver_js_extender to 2.0 + 2. update selenium typing to 3.0.10 + +# 5.3.2 + +## Fixes + +- ([4e0a57c](https://github.com/angular/protractor/commit/4e0a57cff88b470dc5d05698a1341040f65dceb4)) + fix(test): fix async tests + + Increase the scripts timeout + +- ([c6703a5](https://github.com/angular/protractor/commit/c6703a5ea8ce7a837193ecf478c2096d8c6e99e9)) + fix(doc): Spelling updates to comments in plugin.ts(#4797) + + Updated some of the spelling errors/ punctuation mistakes for clearer understanding. +- ([76324b8](https://github.com/angular/protractor/commit/76324b80063152ce67c164b6f048682e71771bb6)) + fix(cli): add more verbose warning if '_debugger' module cannot be found. (#4800) + + +- ([f8f490a](https://github.com/angular/protractor/commit/f8f490a82d0ed6965248e1f78bd2ac7ca91548d9)) + updated CHANGELOG based on sauceSeleniumAddress and sauceSeleniumUseHttp (#4793) + + +- ([6290f27](https://github.com/angular/protractor/commit/6290f27720816dd574ff7a1eccfec6ade1539b71)) + fix(generate-docs): fix generate-docs.sh. (#4765) + + Ignore generated unstaged files before checking out to new branch; otherwise, the git checkout + will fail. + +## Dependencies + +- ([948c7f2](https://github.com/angular/protractor/commit/948c7f267feebfd4c6997d8bc02485b573100197)) + fix(deps): Update saucelabs for security issue. (#4805) + + +# 5.3.1 + +## Features + +- ([cc2234c](https://github.com/angular/protractor/commit/cc2234c762268acab85b6e5d1c13b6480738651b)) + feat(logger): Add log level configuration (#1451) (#4068) + +## Fixes + +- ([c63b99e](https://github.com/angular/protractor/commit/c63b99ee029b6730e4b0702ac7c22b4076049e2a)) + fix(grep): change excluded tests to disabled instead of pending (#4673) + +- ([9348ccf](https://github.com/angular/protractor/commit/9348ccfe65a0488d2929f624e70aef585f72e3ab)) + docs(page_objects): Remove unnecessary "await" and "async" (#4732) + +- ([4898db0](https://github.com/angular/protractor/commit/4898db0940e0c0084e7c538a40986f94dc21e7ec)) + docs(plugins) add protractor-cucumber-steps plugin to plugins.md (#4721) + +- ([a7411b6](https://github.com/angular/protractor/commit/a7411b6a156d45ec2e61f1b6ec951a19d854f5b2)) + docs(page_objects): Add async / await example (#4675) + + +# 5.3.0 + +## Features + +- ([9d87982](https://github.com/angular/protractor/commit/9d8798243d23dd9d338c2eabd11d5a43ab3c31d9)) + feat(config): allow to use newer versions of CoffeeScript (#4567) + CoffeeScript lost the hyphen in the module name about 9 months ago, all the new versions are + going to be released as coffeescript not the coffee-script + +- ([6ba30e0](https://github.com/angular/protractor/commit/6ba30e0b356fdb980cf1f2870ef0b5c6bb22ec4e)) + feat(driverProviders): Add TestObject and Kobiton as driverProviders + Add TestObject and Kobiton as driverProviders + 1. Add testObject and kobiton to driverProviders + 2. Add testObject and kobiton items to cli, config and index + 3. Add instructions for using testObject and kobiton to server-setup + +## Fixes + +- ([a62a154](https://github.com/angular/protractor/commit/a62a15417d559346a75fb6e208359ffa5b6b65f1)) + fix(script): fix compile-to-es5 script (#4676) + make compile-to-es5 script rely on native es6-promise typing + +- ([964baba](https://github.com/angular/protractor/commit/964baba5eac52452350bf1d29a191558595c5f1b)) + fix(clientsidescript): avoid returning the value of test callback in waitForAngular (#4667) + The return value could be interpreted as an error by mistake in some situation + Also fix a wrong if-condition in error reporting + +- ([83e2ba8](https://github.com/angular/protractor/commit/83e2ba878257e9c85775cd52bf70960f0c45917b)) + fix(website): Locator by.name('field_name') (#4653) + +- ([02746dd](https://github.com/angular/protractor/commit/02746dd37726b2647f8f8dbeb1152cd7f902acb0)) + fix(browser): Add space after full stop in error message. (#4594) + Linkifiers interpret the ".If" at the end of the URL as part of the URL. + +- ([7f968e0](https://github.com/angular/protractor/commit/7f968e022a7f7ebcda8955651f2907c1a25ecc22)) + fix(direct): Use config's geckoDriver when specified (#4554) + This change makes the `firefox` capability more closely match `chrome`'s. The `firefox` + capability was not looking for `config_.geckoDriver` like `chrome` was. + +- ([f9df456](https://github.com/angular/protractor/commit/f9df45619b1744e6615e183965fe093f0e4526e6)) + docs(element): fix minor typo in element.ts (#4471) + +- ([65f206e](https://github.com/angular/protractor/commit/65f206e70a2d13762c841da247557b0ebb7fde7d)) + docs(website): updated reference from ignoreSynchronization to waitForAngularEnabled(false). + (#4632) + +## Dependencies + +- ([335680f](https://github.com/angular/protractor/commit/335680f10ab3c5d1de1eab92868c7b30fb7e3d23)) + fix(circleCI): lock the currect version of all dependencies (#4669) + CircleCI was broken by the new release of gulp-clang-format and jasmine + 1. pin the version of gulp-clang-format to 1.0.23 + 2. pin jasmine version to 2.8.0 + 3. add lock file + +# 5.2.2 +## Fixes +- ([b3c7404](https://github.com/angular/protractor/commit/b3c7404258db55a71e7bc4520973c0665cb0ff06)) + Revert "fix(jasmine): Update Jasmine to support Node8 async/await (#4608)" + This reverts commit 5d13b00bca651227eb55616363f7d7eb8a91f8e8. + This commit is unnecessary now, revert this commit to avoid breaking changes in 5.2.1 + +- ([8e5ad1f](https://github.com/angular/protractor/commit/8e5ad1f9b01ec4629fa079609aa8bedee52f0722)) + fix(doc): remove unnecessary config in debugging doc/example (#4622) + +# 5.2.1 +## Features +- ([a62efc6](https://github.com/angular/protractor/commit/a62efc6e401bc1aa7408e3008ccdaa219b528636)) + feat(locators): Add support for regex in cssContainingText (#4532) + +## Fixes +- ([e51f0ec](https://github.com/angular/protractor/commit/e51f0ecb31b7eb361dbf8feaa201ad2fccf9cf14)) + fix(doc): update doc for testing with node 8 async/await and chrome inspector. (#4613) +- ([b204a83](https://github.com/angular/protractor/commit/b204a835976088131f209a5f873f9f786fa05a2e)) + doc(browser-support) improved Firefox documentation (#4553) +- ([8d71a1b](https://github.com/angular/protractor/commit/8d71a1b1b1d314bf0a4ef8c7ecefdd1c7688032e)) + docs(page-objects.md): Refactor the existing Page Object example (#4576) +- ([95dd3ca](https://github.com/angular/protractor/commit/95dd3caf4b90b2d42aa1d5b35b0fd48504f802c3)) + doc(tutorial): added example for element.getAttribute('value') to read text from an input (#4566) + +## Dependencies + +- ([bb63ab0](https://github.com/angular/protractor/commit/bb63ab00046fc300d898a39c03fb6d974fe20b57)) + Update to the latest blocking proxy (#4546) + +## Breaking Changes + +- ([5d13b00](https://github.com/angular/protractor/commit/5d13b00bca651227eb55616363f7d7eb8a91f8e8)) + fix(jasmine): Update Jasmine to support Node8 async/await (#4608) + + Breaking change for TypeScript: + JasmineWD doesn't know anything about async/await, turns off JasmineWD if control flow was + disabled. + + It will affect TypeScript tests that are using async/await and + + a. miss some await keyword in the test.(Previously, this might cause the + test failed silently and be reported as pass), or + + b. use Promise in jasmine expect function + + **Before** + ```ts + await expect(getPromise()).toEqual(42); + ``` + **After** + ```ts + expect(await getPromise()).toEqual(42); + ``` + +# 5.2.0 + +## Fixes +- ([f7e17f3](https://github.com/angular/protractor/commit/f7e17f348e738e1a594870d7ff735f2b7ea1853f)) + fix(clientSideScripts): change protractor to support waiting for hybrid app (#4512) + +- ([4b7cada](https://github.com/angular/protractor/commit/4b7cada1317079c20ddf1bb105303e21adba6e32)) + fix(sauce): bring back sauceProxy as a configuration option (#4419) + +- ([b87159b](https://github.com/angular/protractor/commit/b87159b3fcb379b85727a1beb6fd41a914235cf8)) + fix(website): fix all locator examples to use `element` over `browser.findElement` (#4413) + +- ([768fd39](https://github.com/angular/protractor/commit/768fd393d1084a8da0ec6eeaa57508bf17519a3f)) + fix(local): allow local driver provider to use gecko driver from config (#4412) + +- ([c0b8770](https://github.com/angular/protractor/commit/c0b8770ff1a508205b5cf38b5611918e20028fe3)) + docs(website): fix issue 4246 + +- ([f79938e](https://github.com/angular/protractor/commit/f79938e3d138c7bedc66f8c6748704402ea721c4)) + docs(plugins): add ng-apimock plugin to plugins.md + +- ([ab1afb0](https://github.com/angular/protractor/commit/ab1afb093107f3a63f6e15f8f315e33576bb414d)) + fix(blockingproxy): Start bpRunner strictly after setupDriverEnv + +- ([b85e7ee](https://github.com/angular/protractor/commit/b85e7ee1c53cdc4cfb23dc3d06d40317a27e50e7)) + fix(npmignore): .map files in built directory cause stacktrace lines to nowhere Fixes #4371 + +- ([299fc8d](https://github.com/angular/protractor/commit/299fc8d96b3e5daf632a1c584728214ababcebf8)) + docs(browser-support): Fixed incorrect example + +- ([e5a5d59](https://github.com/angular/protractor/commit/e5a5d59fcabe15860b30944e714bbd8e81ceaeae)) + docs(frameworks) align cucumberOpts comments + +- ([fe8c480](https://github.com/angular/protractor/commit/fe8c480bd860209cc68768de884d050cbf1a5b27)) + docs(frameworks) update cucumber dry run option + +- ([2e9acf5](https://github.com/angular/protractor/commit/2e9acf58b76b553c558f56b6a38c161ad50324de)) + docs(plugins) add protractor-numerator plugin to plugins.md + +- ([3f861ae](https://github.com/angular/protractor/commit/3f861ae069df98a06cfa1ede89f56a8d0ec9d5d2)) + By.js locator should accept functions + +## Dependencies + +- ([0fbc2c0](https://github.com/angular/protractor/commit/0fbc2c0ac12992bd61712188a96aef6684bef0c1)) + chore(release): update selenium-webdriverjs + + +# 5.1.2 + +## Features + +- ([dd2ccbb](https://github.com/angular/protractor/commit/dd2ccbb1b73b7c90647837cd1c4f6b16b3f6b0ac)) + feat(saucelabs): Add Sauce Labs protocol customization support + + New option `sauceSeleniumUseHttp` available in `protractor.conf.js` + If true, uses 'http' instead of 'https' to connect to Sauce Labs defined by `sauceSeleniumAddress` + +## Fixes + +- ([1a47076](https://github.com/angular/protractor/commit/1a47076875395648038a39fcd258a77bfcabe05c)) + fix(ci): Use latest pip on CircleCI + +- ([fd59c78](https://github.com/angular/protractor/commit/fd59c78407ced4f17e1b4ed4451ce463439aa3c9)) + fix(elementexplorer): Set script breakpoints with cross-platform safe paths. + + Fixes #4011 + +- ([1250278](https://github.com/angular/protractor/commit/12502784b306cbedca8684486c31eeb361da5897)) + fix(cli): Correctly parse list chromeOptions + + Chromedriver requires that certain options always be passed as an array. Optimist passes + --single-option as a string instead of an array which is invalid. This ensures that we always pass + an array, even if a single option is passed via the cli. + + Fixes #4050 + +- ([183cd80](https://github.com/angular/protractor/commit/183cd803254f7a3ccb3a8650e8ef06b4fff03446)) + fix(browser): Fix browser.angularAppRoot() + + By default, it wasn't returning anything. Now it returns a promise that resolves to + internalAngularAppRoot. Fixes #4233 + +- ([bd534fb](https://github.com/angular/protractor/commit/bd534fb8b2dfaca9072914dc84ad662891a8c7b2)) + fix: Add "stackTrace" option to allowedNames in cli.ts + + This fixes a problem I encountered similar to #4196 - where `stackTrace` is listed as an option + but an error is given saying it's an "unknown extra flag" + +- ([8249167](https://github.com/angular/protractor/commit/82491678de71b43311ea68d496ff807e1c72ee5e)) + fix: export Runner, not just its type. (#4227) + +- ([0eb5b76](https://github.com/angular/protractor/commit/0eb5b7608e4bfb770878fe443d97ed9aa426c070)) + fix(navigation): ignore unknown JS errors in IE (#4149) + + The `err` object doesn't have the `code` property any more (Selenium Server Standalone 3.3.1 + + IEDriver win32 3.3.0), so we need a new way to detect those errors. See #841 +- ([4752ad1](https://github.com/angular/protractor/commit/4752ad1287af536c6dd442dd8c74546f978627d9)) + chore(examples): Fix TSC issues with exampleTypescript (#4132) + + +## Dependencies + +- ([a0a1fac](https://github.com/angular/protractor/commit/a0a1fac8568f2bfbd6d5721db438aed390e30d23)) + chore(deps): Updating webdriver-manager and jasminewd2 + + +# 5.1.1 + +## Features + +- ([3edd62e](https://github.com/angular/protractor/commit/3edd62eccccb67ec7cb71b8c3d8b2c2921a6f7ca)) + feat(saucelabs): Add Sauce Labs HTTPS Support (#4071) + +- ([29f975a](https://github.com/angular/protractor/commit/29f975a34f5885a21525c3746bd3e82d5ae0c51e)) + feat(plugins): allow plugins to know which browser instance to run against (#4066) + + Closes https://github.com/angular/protractor/issues/4054 + +## Dependencies + +- ([9d69a81](https://github.com/angular/protractor/commit/9d69a819c96e408df2b59589d49811a89af1bc74)) + deps(typescript): use typescript@~2.0.0 (#4062) + + - move noCF tests to install and fix reference to protractor + - changed element.ts to not use keyof + - remove gulp task tsc:spec + +## Breaking Changes + +- The protocol for a Sauce Labs selenium relay (sauceSeleniumAddress in protractor.conf.js) + is 'https' (previously used 'http'). The protocol is not configurable in this version. + + +# 5.1.0 + +#### Blocking proxy + +Blocking Proxy is a new experimental feature in Protractor 5 and is behind the +`--useBlockingProxy` or `blockingProxyUrl`. See the +[lib/config.ts#L100](https://github.com/angular/protractor/blob/master/lib/config.ts#L100). +Other ways to start blocking proxy include using the +`--highlightDelay` and `--webDriverLogDir` flags See [lib/config.ts#L501](https://github.com/angular/protractor/blob/master/lib/config.ts#L501). + +This adds two options, both of which are implemented with Blocking +Proxy. `--webDriverLogDir` will create a readable log with timing +information of webdriver commands in the specified directory. + +`--highlightDelay` will pause before clicking on elements or sending keys. +While paused, the element that's about to be affected will be +highlighted. + +#### Webdriver-manager + +Webdriver-manager will now by default grab the latest versions of all binaries +(standalone, chromedriver, iedriver, gecko driver). Use the +`--versions.(binary name)` to pin to a specific version. Selenium standalone +3.0.1 has a bug which prevents it from working with any version of FireFox. +We have tested version 3.0.0-beta4 and know that it works with +FireFox 51, and we expect that the 3.0.2 release will also work. + +#### TypeScript support + +For jasmine users, in order to get all the type declarations that are used in +jasminewd2, you'll need to install `@types/jasminewd2` in addition to +`@types/jasmine` as dev dependencies. + +## Features + +- ([0cd156d](https://github.com/angular/protractor/commit/0cd156d6829f23f93403d865b7fdb7eab4f45446)) + feat(debugging): Add webdriver logging and highlight delay. (#4039) + + This adds two options, both of which are implemented with Blocking + Proxy. --webDriverLogDir will create a readable log with timing + information of webdriver commands in the specified directory. + + --highlightDelay will pause before clicking on elements or sending keys. + While paused, the element that's about to be affected will be + highlighted. + +- ([3d98a16](https://github.com/angular/protractor/commit/3d98a1668138d36681bf305c9ea67dd1eea38899)) + feat(config): Support setting `SELENIUM_PROMISE_MANAGER` flag via the config (#4023) + + Closes https://github.com/angular/protractor/issues/3691 +- ([4e40fb1](https://github.com/angular/protractor/commit/4e40fb175e64820bbab24efb376dac80fa6ba2b0)) + feat(browser): chain promises in `browser.get` (#4017) + + Closes https://github.com/angular/protractor/issues/3904 +- ([33393ca](https://github.com/angular/protractor/commit/33393cad633e6cb5ce64b3fc8fa5e8a9cae64edd)) + feat(browser): chain some promises in `lib/browser.ts` + return promise from + `waitForAngularEnabled` (#4021) + + Minor breaking change since `waitForAngularEnabled` no longer returns a boolean + Part of angular#3904 + Chaining `browser.get` has proved surprisingly complex, so I'll do that in a different PR + Also fixed a minor bug in `lib/clientsidescripts.js` while debuging +- ([7cb9739](https://github.com/angular/protractor/commit/7cb9739954bc26f0667d671cdb0083f5bd43f2f6)) + feat(browser.ready): make `browser.ready` wait for all async setup work (#4015) + + Closes https://github.com/angular/protractor/issues/3900 +- ([b77cb92](https://github.com/angular/protractor/commit/b77cb928301fbe4f77ffcdcace424a490581416e)) + feat(restart): `browser.restart` should return a promise (#4008) + + Also allows `browser.restart` to work when the control flow is disabled, and + fixes it for forked browsers. + + Closes #3899 and #3896 + https://github.com/angular/protractor/issues/3896 + +- ([4a59412](https://github.com/angular/protractor/commit/4a59412357eb5df592b06dd282d88d6dbc5e4771)) + feat(angularAppRoot): Replace rootEl with browser.angularAppRoot() (#3996) + + Replace browser.rootEl with browser.angularAppRoot(), which changes the root element in a promise + on the control flow. Note that browser.rootEl will immediately return the current value, but + browser.angularAppRoot() will return a promise that resolves during the next step in the control + flow. + + Also update to BlockingProxy 0.0.3, which allows changing rootSelector. + +- ([879aac6](https://github.com/angular/protractor/commit/879aac6ee6c1c36d005b538472e2754b987b3368)) + chore(blockingproxy): Allow using a pre-existing Blocking Proxy instance (#3970) + +- ([bf123ad](https://github.com/angular/protractor/commit/bf123adafc442440b2ca10725113b47342ebb24f)) + feat(elements): Add isPresent() to ElementArrayFinder. (#3974) + +## Bug Fixes + +- ([f9bee84](https://github.com/angular/protractor/commit/f9bee84bc03b6cd6872522b8780327423b789e19)) fix(restart): preserve waitForAngularEnabled on restart and add promise chaining + + I noticed I missed `waitForAngularEnabled` in #4037. This commit fixed that. + + While I was at it I fixed a minor error where the promises implicitly created by + setting `rootEl` and `ignoreSynchronization` weren't getting chained properly. + + Also fixed minor (so minor I think it was impossible to trigger) where + browser.plugins_ could be undefined. + +- ([0b0c224](https://github.com/angular/protractor/commit/0b0c224e4056368c2c0030064b4ca4235163276b)) + fix(plugins): do not force ManagedPromise in plugins.ts (#4036) + +- ([9c2274d](https://github.com/angular/protractor/commit/9c2274d8f218cabc946dbc6a11d725458c1b4e3a)) + fix(restart): preserve properties like `browser.baseUrl` upon restart (#4037) + + I also fixed a minor issue where `internalRootEl` wasn't being set when blocking proxy was being + used. I also just cleaned up our internal uses of `this.rootEl`. + + Closes #4032 + +- ([a20c7a7](https://github.com/angular/protractor/commit/a20c7a7cc1df04f96cb1a9dd971df39883ac173b)) + fix(element chaining): make element chaining work when the control flow is disabled (#4029) + + Also added some tests to `spec/ts/noCF/smoke_spec.ts` double checking that the control flow is off + +- ([7481dee](https://github.com/angular/protractor/commit/7481dee75cab1da9d207909e928eee55a9f5a682)) + fix(cli): Make unknown flag check a warning instead of an error. (#4028) + +- ([40bbeca](https://github.com/angular/protractor/commit/40bbeca003017901760e10831c66d383cf5accf8)) + fix(expectedConditions): Add tests and fix race conditions around visibility (#4006) + + Add test cases to reproduce the missing element race conditions possible in + expected condition methods `visibilityOf`, `textToBePresentInElement`, + `textToBePresentInValue` and `elementToBeClickable`. + + Add error handler `falseIfMissing` to all expected conditions that depend + on the presence of an element. + + Expected conditions check the presence of an element before other checks, + but when an element is removed exactly in the moment after the `isPresent` + and before `isDisplayed` in `visibilityOf` the condition used to fail. + + This solution does not handle missing elements in (`isEnable`, `isDisplayed`, + `isSelected`) and focused only on expected conditions (see #3972) + + This problem was also referenced in #3578 and #3777 + +- ([5856037](https://github.com/angular/protractor/commit/5856037368ee8d8a21f11eadbfe93d5f46507f60)) + fix(cli): Allow frameworks to specify flags they recognize. (#3994) + + Fix for #3978. + Our initial plan to allow setting --disableChecks with an environment variable is insufficient, + since the custom framework isn't even require()'d until after the config is parsed. This moves the + unknown flag check into the runner, and gives frameworks a way to specify extra flags they accept. +- ([e68dcf1](https://github.com/angular/protractor/commit/e68dcf1bfd7f32c59ebd23fa16ca53e1a53f8ddf)) + fix(driverProviders): Check config in the right place. (#3991) + +- ([eb89920](https://github.com/angular/protractor/commit/eb899208457f83853f043edea5e56b07e87803bc)) + fix(driverProviders): Handle promise rejection when starting selenium (#3989) + + Fixes #3986. Also error if jvmArgs isn't an array. + +- ([8d2fc07](https://github.com/angular/protractor/commit/8d2fc07ed28a1b19c03a9869442f76f2963e40a1)) + chore(browser): deprecate `browser.getLocationAbsUrl()`. (#3969) + + Closes #3185 +- ([15a1872](https://github.com/angular/protractor/commit/15a187204bb8b87255d5f4622094eabc71206315)) + fix(firefox): Fix directConnect for Firefox 51+ (#3953) + +- ([81f56a4](https://github.com/angular/protractor/commit/81f56a449f8988feba21617ef7533cfa2f06c6f8)) + fix(cli): display disableChecks option in extra flags error message (#3964) + +- ([6a4dc7a](https://github.com/angular/protractor/commit/6a4dc7a6a5b796e0215e5b9abf99494ac13cb647)) + fix: no longer use es6 let statement (#3963) + + * Currently in Protractor v5 the Angular detection script uses ES6 features like the `let` modifier. + + This can break Protractor on browsers, which doesn't support those statements. + > See https://saucelabs.com/beta/tests/275f75091dac40a0a3374d29d912caee/commands#11 + +- ([528338c](https://github.com/angular/protractor/commit/528338c6722219fdcfc51153b0031a02f0fce046)) + fix(expectedCondition): fix NoSuchElementError in visibilityOf due to a race condition (#3777) + + Handle NoSuchElementError in the expected condition visibilityOf, which occurred when + an element disappears between the isPresent() and isDisplayed() check. + +## Dependencies + +- ([5899b67](https://github.com/angular/protractor/commit/5899b676bc2db0005506ae2306350e6ffea3c808)) + deps(update): update webdriver-manager to ^12.0.1 (#4042) + + Running `webdriver-manager update` will now by default grab the latest + versions of all binaries (standalone, chromedriver, iedriver, gecko + driver). You can continue to pin to a specific versions using the + command line option. Example `webdriver-manager update --versions.chrome 2.20`. + As of this release the latest versions are: + + - gecko v0.14.0 + - selenium-standalone 3.0.1 is the latest jar file; however, we recommend 3.0.0-beta4. See note + below on Firefox support. + - chromedriver 2.27 + - iedriver 3.0.0 + + A note on FireFox support: Selenium standalone 3.0.1 has a bug which prevents it from working + with any version of FireFox. We have tested version 3.0.0-beta4 and know that it works with + FireFox 51, and we expect that the 3.0.2 release will also work. + + closes #4033 + +- ([cd084a0](https://github.com/angular/protractor/commit/cd084a0ca29cd73aa3ce1650188adf7ddfdb7962)) + deps(jasmine): update jasmine to ^2.5.3 (#3960) + +# 5.0.0 + +This version includes big changes around upgrading to selenium-webdriver 3.0.x. +See the [selenium-webdriver changelog](https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/CHANGES.md). + +For the 5.0.0 release, we are still using the selenium standalone server 2.53.1 +and recommend using Firefox 47. Firefox 48+ currently is not supported. + +## Breaking Changes + +- Minimum node version is now 6.9.x. +- When testing with Firefox 47, use the capability option `marionette: false` + to use the legacy Firefox driver. + + Before: + ``` + capabilities: { + browserName: 'firefox' + } + ``` + + After: + ``` + capabilities: { + browserName: 'firefox', + marionette: false + } + ``` + +- We moved `@types/jasmine` to a devDependency. This means that Jasmine + TypeScript users will need to include the `@types/jasmine` as a project + dependency. This is to avoid conflicts for users that prefer mocha typings. + + After: + ``` + "dependencies": { + "@types/jasmine": "^2.5.38" + } + ``` + +- Selenium-webdriver methods removed: `WebDriver.prototype.isElementPresent`, + `WebElement.prototype.getRawId`, `WebElement.prototype.getInnerHtml`, and + `WebElement.prototype.getOuterHtml`. + + Before: + ``` + let isPresent = browser.driver.isElementPresent(By.tagName('a')); + let i = element(locator).getInnerHtml(); + let o = element(locator).getOuterHtml(); + ``` + + After: + ``` + let isPresent = element(By.tagName('a')).isPresent(); + let i = browser.executeScript("return arguments[0].innerHTML;", element(locator)); + let o = browser.executeScript("return arguments[0].outerHTML;", element(locator)); + ``` + +- Selenium-webdriver `ErrorCodes` have been removed. +- Adding cookies have been changed: + + Before: + ``` + browser.manage().addCookie('testcookie', 'Jane-1234'); + ``` + + After: + ``` + browser.manage().addCookie({name:'testcookie', value: 'Jane-1234'}); + ``` +- Removed `protractor.wrapDriver()`. +- You can no longer use `repl` command from within `browser.pause()`. Instead, + use `browser.explore()` to directly enter the `repl`. +- Sending flags that are not recognized by the CLI throws an error. Since flags + are a subset of all configuration options, these errors can be silenced with + `--disableChecks`. +- Auto-detection of the root element. This is a breaking change because it + changes the default root element behavior and removes the + `config.useAllAngular2AppRoots` flag. Modern angular apps now + default to using all app hooks, and ng1 apps now check several places, notably + the element the app bootstraps to. +- `sauceProxy` configuration field has been removed. Use `webDriverProxy` + instead. + + Before: + ``` + sauceProxy: 'http://sauceProxy' + ``` + + After: + ``` + webDriverProxy: 'http://sauceProxy' + ``` + +## Features + +- ([ec93c4a](https://github.com/angular/protractor/commit/ec93c4ab882991410ad9d3f52d87c0f5ec947641)) + chore(cli): **breaking change** throw errors on unknown flags (#3921) + + Unknown flags are options sent that is unrecognized by the CLI. For users that + encounter this error but would like to silence it, use: `--disableChecks`. + + closes #3216 +- ([bc58332](https://github.com/angular/protractor/commit/bc583321a233453fc2b89472013b2ec3e1d6b6f9)) + feat(rootEl): ***breaking change*** auto-detect the root element better (#3928) + + This is a breaking change because it changes the default root element behavior + and removes the `config.useAllAngular2AppRoots` flag. Modern angular apps now + default to using all app hooks, and ng1 apps now check several places, notably + the element the app bootstraps to. + + closes #1742 +- ([604fdbf](https://github.com/angular/protractor/commit/604fdbf064cc2785a2e745747beeaeb45d27f8ed)) + cleanup(config): **breaking change** Remove redundant sauceProxy config (#3868) + + Removes the `sauceProxy` config field, and uses `webDriverProxy` when creating + the SauceLabs client. +- ([9465b9f](https://github.com/angular/protractor/commit/9465b9f1e667c9590e05d9ddac16fe5143aa93af)) + feat(mobile): add extended wd commands for appium (#3860) + + Also had to make some minor changes to the website to handle longer inheritance + chains + Closes https://github.com/angular/protractor/issues/1940 +- ([0e26b21](https://github.com/angular/protractor/commit/0e26b218d5f385dd9871a40553acc174cfdfe26d)) + feat(blockingproxy): Add synchronization with BlockingProxy. (#3813) + + This adds support for BlockingProxy behind the flag --useBlockingProxy. + + If set, the driver providers will start a proxy during their setup phase, + passing the selenium address to the proxy and starting a webdriver client + that talks to the proxy. + + Starting a proxy for each driver provider isn't strictly necessary. However, + when we run with multiple capabilities it's easier to handle the logging if + each Protractor instance has it's own proxy. + + Known issues: + + - Doesn't work with directConnect. You can get the address of chromedriver by + mucking around in Selenium internals, but this probably changed for Selenium + 3.0 and I doubt it's worth figuring out until we upgrade. + - Doesn't yet work with webDriverProxy (but it's an easy fix) + +- ([ca4f1ac](https://github.com/angular/protractor/commit/ca4f1acda3672942307d0f102d586c8889dd3d68)) + chore(driverProviders): add warnings to extra driver provider parameters (#3873) + + - builds the driver provider in lib/driverProviders/index instead of lib/runner + closes #1945 + +- ([681b54a](https://github.com/angular/protractor/commit/681b54a21ee1467d5a95c3693cde148759767d62)) + refactor(browser): Remove protractor.wrapDriver() **breaking change** (#3827) + + Before: + + Users could create their own selenium driver instance and enable Protractor on + it like so: + + ```js + let capabilities = webdriver.Capabilities.chrome(); + let driver = new webdriver.Builder().usingServer(seleniumAddress) + .withCapabilities(capabilities).build(); + let browser = protractor.wrapDriver(driver); + ``` + + Over the years, wrapDriver() has become increasingly broken as Protractor + needs extra configuration options that wrapDriver() doesn't set. + + After: + + This method is removed. If users need a new browser instance, they can + use `browser.forkNewDriverInstance()`. + +- ([86fd569](https://github.com/angular/protractor/commit/86fd56917f039efbff8e6f323f4d91fa8bc821a4)) + feat(ngUpgrade): Auto detect ngUpgrade apps and make the ng12Hybrid flag + unnecessary for most users (#3847) + + +## Bug fixes + +- ([de153e7](https://github.com/angular/protractor/commit/de153e769292f6b9a99b2d5152bd2929ab1c48af)) + fix(launcher): running getMultiCapabilities should reject on errors (#3876) + + closes #3875 +- ([1345137](https://github.com/angular/protractor/commit/1345137dc5173e868de4b9da6ed16b7928e4c50e)) + fix(isElementPresent): for un-wrapped `WebElement`s, `browser.isElementPresent` + was broken (#3871) + + Closes #3864 +- ([4af3b2e](https://github.com/angular/protractor/commit/4af3b2e30e925ea9d8e47537ea0a7fe8f04b579d)) + fix(element): Fix typing of ElementFinder.then (#3835) + + Type `then` as optional on ElementFinder. + + +## Dependencies +- ([4d87c9c](https://github.com/angular/protractor/commit/4d87c9c20d6905189c0e7ea7214cf3e87c8efe91)) + deps(update): update tslint and @types/selenium-webdriver (#3941) + + - use @types/selenium-webdriver ~2.53.39 + - fix for tslint + + closes #3939 +- ([7376708](https://github.com/angular/protractor/commit/7376708c723976ef8a0a3ad7c245606bef1221db)) + deps(tslint): set tslint to ~4.2 (#3938) +- ([cb38ed0](https://github.com/angular/protractor/commit/cb38ed0a8aae2cb862001e0b6f076aa9972f4489)) + Refactor element explorer to work with selenium-webdriver 3 (#3828) + + This implementation now relies mostly on promises explicitly, so the control + flow is only used to add one large task to the queue. This should pave the way + for the eventual removal of the control flow, as well as getting element + explorer to work immediately. + + BREAKING CHANGE + + You can no longer use the `repl` command from within `browser.pause()`. Instead, + use `browser.explore()` to directly enter the repl. +- ([8196059](https://github.com/angular/protractor/commit/819605933d2dfef70b4332a727b3b3830e306817)) + chore(dependency): switch to webdriver-manager 11.1.0 and remove + `--versions.chrome 2.26` from circle.yml (#3865) +- ([397bf65](https://github.com/angular/protractor/commit/397bf65e088b640cf3612f9da678180f49939b84)) + deps(update): move @types/jasmine to devDependencies (#3795) + + - update outdated dependencies + - move @types/jasmine to devDependencies + closes #3792 +- ([a3e8b43](https://github.com/angular/protractor/commit/a3e8b4319d3e8b049e55e5c3c64a7fdb5a132ddf)) + deps(selenium-webdriver): upgrade to selenium 3 (#3781) + + Please see the [selenium-webdriver changelog](https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/CHANGES.md) + + - Removed method `WebDriver.prototype.isElementPresent` + - Removed method `WebElement.prototype.getRawId` + - Removed `getInnerHtml` and `getOutterHtml` + + - Dependency required for upgrade: use `jasminewd2@0.1.0`. + - Selenium-webdriver requires node version 6+, updating travis and circle yml + to use node 6 and 7. + + - Use `instanceof` selenium-webdriver error instead of error code. + Selenium-webdriver error codes have been deprecated. + + - Use executor with selenium-webdriver from `lib/http`. Deferred executor has + been deprecated. + - Fix quitting `driverProviders`. When calling `webdriver.quit`, the control + flow is shutdown and will throw an error. + - Driver provider for direct connect has been modified to use `ServiceBuilder` + and to call the `Service` to `createSession` + - Note: Since this upgrade is still using FF 47, direct connect for Firefox is + required to pass "marionette: false" in the capabilities. If you do not pass + marionette to false, it will look for gecko driver in the PATH. + - Added a TODO to support FF after 48+ with direct connect and gecko driver. + + - Updated `browser.manage().addCookie('testcookie', 'Jane-1234');` to use + `browser.manage().addCookie({name:'testcookie', value: 'Jane-1234'});` + + - Updated debug commons for breakpoint updated to selenium-webdriver + `lib/http` line 432. + + - For mocha tests, `selenium-webdriver/testing` uses the global `it` and + cannot be reassigned as Protractor's global `it`. Some code has been + copied / modified to `lib/frameworks/mocha` to make this work. + + - Capabilities for Firefox 47 requires setting marionette to false. + - Setup still requires selenium standalone server 2.53.1 for Firefox tests. + Firefox version used is 47. + - Using selenium standalone server 3, with Firefox 48+ tests fail with gecko + driver still do not work. + - Selenium standalone 3 + FF 49 + gecko driver 0.11.1 does not work + - Selenium standalone 3 + FF 48 + gecko driver 0.11.1 appears to work for a + single test but after it quits, selenium standalone no longer works with + firefox. When firefox 48 exists, logs show the following: + + ``` + 20:01:14.814 INFO - Executing: [delete session: e353fa1b-e266-4ec3-afb3-88f11a82473a]) + [GFX1-]: Receive IPC close with reason=AbnormalShutdown + [Child 30665] ###!!! ABORT: Aborting on channel error.: file /builds/slave/m-rel-m64-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2052 + [Child 30665] ###!!! ABORT: Aborting on channel error.: file /builds/slave/m-rel-m64-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2052 + ``` +- ([eb31c9c](https://github.com/angular/protractor/commit/eb31c9c7755399bcd01630158d900e0b940e9c31)) + deps(types): update @types/selenium-webdriver dependency (#3886) + + Fixes issue #3879 and adds the protractor.Key.chord method + +# 4.0.14 + +## Bug Fixes + +- ([83694f5](https://github.com/angular/protractor/commit/83694f5e66592c5e229db98af3733ff73dac8392)) + fix(types): update for selenium-webdriver types creating transpile errors (#3848) + + - pin package.json to a specific version of @types/selenium-webdriver + +- ([ea09be4](https://github.com/angular/protractor/commit/ea09be4ff0750d1d0873677fac9055a9acb630b3)) + fix(jasmine): Return the full test name in Jasmine test results. (#3842) + + Fixes #3510 + +- ([76cb4b4](https://github.com/angular/protractor/commit/76cb4b4c2ac892f9785dc1506cbc0b490eea91fe)) + fix(element): Fix typing of then function (#3785) + +- ([5a12d69](https://github.com/angular/protractor/commit/5a12d69f34fd80234455bbe6457e125a27a07e54)) + fix(config): cucumberOpts.require should be an optional Array of strings (#3817) + + - Both cucumber options require and format now support `string` or `string[]` see #3822 #3817 + - Remove no longer available options and fix `dryRun` type + - Update comment for `dryRun` + +## Features + +- ([b337a8e](https://github.com/angular/protractor/commit/b337a8e8547af0b90663a35b07fd30b55ff61dd0)) + feat(config): add seleniumServerStartTimeout (#3791) + +## Dependencies + +- ([688f5d6](https://github.com/angular/protractor/commit/688f5d6a089275ac99688196cd66f345c64adfec)) + deps(update): update vrsource-tslint-rules and webdriver-manager (#3856) + +- ([c437fd3](https://github.com/angular/protractor/commit/c437fd3315278e7536a8385a9769e4fbd954d0a6)) + deps(selenium-webdriver): clean up types selenium-webdriver (#3854) + + +# 4.0.13 + +## Bug Fix + +- ([c3978ec](https://github.com/angular/protractor/commit/c3978ec166760ac07db01e700c4aaaa19d9b5c38)) + fix(revert): element(locator).then should not appear in the docs and change reverted. (#3808) + + - change comments to not be in JSDoc format + - reverts change `element(locator).then` + +# 4.0.12 + +## Bug Fixes + +- ([742f264](https://github.com/angular/protractor/commit/742f26465ca926c39bf28f03390a45030c15acf3)) + fix(driverProviders): quit forked instances w/ local driver provider (#3787) + + - fix driver provider quit session to not throw error and quit + - should fix sauce labs test, enabling expected conditions test with forked instance + - checked that chromedriver does not persist in the background + - add local driver test with forked instance to test suite + - organize attach session and local specs to driverProviders directory + closes #3780, closes #3779, closes #3772 +- ([7d481d6](https://github.com/angular/protractor/commit/7d481d6886b39cb476b889de5d14186bda6dc066)) + fix(ExpectedConditions): non-static ExpectedConditions for browser (#3766) + + - Update sauce lab binary to run on travis. + - Disable expected conditions test that forks the browser. This issue appears to + not be specific to sauce labs. Also can reproduce this with a local driver + provider. Additional work is required around driver providers and the runner. + - Add TODO to enable test in the future when this is resolved. + closes #3761 + +# 4.0.11 + +## Features + +- ([6ebee72](https://github.com/angular/protractor/commit/6ebee72088016085e93d268effabcbe0b3d0a70f)) + feat(config): Add 'random' and 'seed' jasmine config options (#3467) + +## Bug Fixes + +- ([2048182](https://github.com/angular/protractor/commit/2048182206e88dd4cde0e92cfac3ed97cbe38f15)) + docs(timeout): Update timeout error message and docs (#3723) + +- ([f3938f9](https://github.com/angular/protractor/commit/f3938f9fcd1b91272f2f11d4d39e458576fb75b0)) + fix(jvmArgs): fixes jvmArgs launching selenium from config (#3698) + + closes #3697 + +- ([21d534f](https://github.com/angular/protractor/commit/21d534fad28f84e8cef166348119387e49661227)) + fix(types): Make element.then()'s signature more broad. (#3719) + +- ([e9061b3](https://github.com/angular/protractor/commit/e9061b30c3673344d776187682d1c735aaad69f7)) + chore(types): make plugins.ts more strongly-typed (#3685) + +- ([f42e0b3](https://github.com/angular/protractor/commit/f42e0b3dc824404ac0c86364bf5de4b657cf30ea)) + fix(globals): Resolve exported globals dynamically. (#3716) + + fixes #3677 + +- ([d7fa744](https://github.com/angular/protractor/commit/d7fa74464709c532d451fdead78bc57b21956784)) + fix(util): Fix adding stack traces to Errors thrown as strings (#3687) + +## Dependencies + +- ([a1c8a23](https://github.com/angular/protractor/commit/a1c8a23fea3542eabeae6e7bc59f3c2ffa0fda94)) + chore(deps): Downgrade jasmine to 2.4.1 (#3715) + + Upgrading to 2.5.2 causes #3606. We'll need to wait on a fix for jasmine/jasmine-npm#95 before + upgrading. + +# 4.0.10 + +## Features + +- ([7083426](https://github.com/angular/protractor/commit/70834269ac375f2be5a6cadf8ec9169cf19abff6)) + feat(hybrid): set ng12hybrid flag in the config (#3452) + +## Bug Fixes + +- ([b67d8eb](https://github.com/angular/protractor/commit/b67d8eb4101ee80c53476d1640865ca612793436)) + fix(restart): typescript fix for browser.restart (#3658) + + closes #3648 + +- ([6626ce7](https://github.com/angular/protractor/commit/6626ce7690e1120c3b246eff7793a26cb038b091)) + fix(launcher) Ignore uncaught exceptions from webdriver. (#3608) + + +- ([5cef1bf](https://github.com/angular/protractor/commit/5cef1bf20f88a2c3bb8944afbc6a328fc273aedd)) + Explicitly remove newlines from getText() (#3618) + + MSEdge does not properly remove newlines, which causes false negatives when using + `textToBePresentInElement()` + +## Dependencies + +- ([c11945a](https://github.com/angular/protractor/commit/c11945a1b67bdc774b267f101887dc3f575ad00b)) + deps(outdated): webdriver-manager and @types updated + + - webdriver-manager 10.2.6 uses the latest chromedriver, version 2.25 + # 4.0.9 This version includes a breaking change to the TypeScript import statement. Please see the feature below. -# Features +## Features - ([5034c89](https://github.com/angular/protractor/commit/5034c89242794dd14aba294ba3468937e06a7b69)) feat(typescript): move typescript variable instances from protractor/… (#3565) diff --git a/DEVELOPER.md b/DEVELOPER.md new file mode 100644 index 000000000..f64109172 --- /dev/null +++ b/DEVELOPER.md @@ -0,0 +1,150 @@ +# Building and Testing Protractor + +This document describes building, testing, releasing Protractor and provides an overview of +the repository layout. + +## Prerequisite software + +The prerequisite software (Node.js, npm, git, jdk) are the same as for angular. See +https://github.com/angular/angular/blob/master/docs/DEVELOPER.md#prerequisite-software + +## Getting the sources + +Fork Protractor from github, then clone your fork with: + +```shell +git clone git@github.com:/protractor.git + +# Go to the Protractor directory: +cd protractor/ + +# Add the main protractor repository as an upstream remote to your repository: +git remote add upstream https://github.com/angular/protractor.git +``` + +## Installing and Building + +All Protractor dependencies come from npm. Install with: + +```shell +npm install +``` + +This will also trigger our build step. The build step runs the TypeScript compiler +and copies necessary files into the output `built` directory. To run the build step +independently, run: + +```shell +npm run prepublish +``` + +You can see the other available npm scripts in `package.json`. Note that most of these +scripts just call our `gulp` commands, which can be seen in `gulpfile.js`. + +## Formatting + +Protractor uses clang-format to format the source code. If the source code is not properly formatted, +the CI will fail and the PR can not be merged. + +You can automatically format your code by running: + +```shell +npm run format +``` + +You can check that you will pass lint tests with: + +```shell +gulp lint + +# or if you don't have gulp installed globally: +./node_modules/.bin/gulp lint +``` + +## Code layout + +`docs/` contains markdown documentation files. +`lib/` contains the actual Protractor code. +`scripts/` contains scripts used for CI setup and running tests. +`spec/` contains e2e and unit tests and configuration files for tests. +`testapp/` contains the code for the Angular applications that e2e tests run against. +`website/` contains code for generating Protractor API documentation and the website at protractortest.org. + +Most of the code is written in TypeScript, with the exception of a few js files. + +`lib/driverProviders` controls how WebDriver instances are created. +`lib/frameworks` contains adapters for test frameworks such as Jasmine and Mocha. +`lib/selenium-webdriver` and `lib/webdriver-js-extender` are used ONLY for API documentation generation. + +## Lightning Code Walkthrough + +TBD. + +## Testing + +Run `npm test` to run the full test suite. This assumes that you have the testapp and a +selenium server running. Start these as separate processes with: + +```shell +webdriver-manager update +webdriver-manager start +``` + +and + +```shell +npm start +``` + +This suite is described in `scripts/test.js`. It uses some small helper functions to run commands +as child processes and capture the results, so that we can run protractor commands which should +result in failures and verify that we get the expected number and type of failures. + +The suite contains unit tests, end to end tests using the built binary, and interactive tests. +Interactive tests are for testing `browser.pause` and element explorer. + +End to end tests all have configuration files which live in `spec/`. Many tests do not need +an actual Selenium server backing them and use the `mockSelenium` configuration, which saves +time by not connecting to a real selenium server. + +## Important dependencies + +Protractor has very close dependencies with several other projects under the Angular umbrella: + +`jasminewd2` is an extension of the Jasmine test framework that adds utilities for +working with selenium-webdriver. [jasminewd](https://github.com/angular/jasminewd) + +`blocking-proxy` is a separate binary, which handles traffic between a test script and +webdriver. It can be turned on via a protractor configuration file, and in the future +all logic to wait for Angular will be handled through the blocking proxy. +[blocking-proxy](https://github.com/angular/blocking-proxy) + +`webdriver-manager` is a separate binary which manages installing and starting up +the various binaries necessary for running webdriver tests. These binaries include +specific drivers for various browsers (e.g. chromedriver) and the selenium standalone +server. [webdriver-manager](https://github.com/angular/webdriver-manager) + +`webdriver-js-extender` extends selenium-webdriver to add Appium commands. +[webdriver-js-extender](https://github.com/angular/webdriver-js-extender) + +## Continuous Integration + +PRs or changes submitted to master will automatically trigger continuous integration on two +different services - Travis, and Circle CI. We use Travis for tests run with SauceLabs because +we have more vm time on Travis and their integration with SauceLabs is smooth. CircleCI gives us +greater control over the vm, which allows us to run tests against local browsers and get better +logs. + +Travis runs e2e tests via SauceLabs against a variety of browsers. The essential browsers run a +more complete test suite, `specified by spec/ciFullConf.js`. We also run a set of smoke tests +against a larger set of browsers, which is allowed to fail - this is configured in +`spec/ciSmokeConf.js`. This is due to flakiness in IE, Safari and older browser versions. +We also run a small set of tests using BrowserStack to verify that our integration with their +Selenium farm works. + +Circle CI runs a slightly modified version of `npm test` in a single VM. It installs +the browsers it needs locally. Circle CI runs unit tests and a set of e2e tests against Chrome. + +## Releasing + +See [release.md](https://github.com/angular/protractor/blob/master/release.md) for full instructions. diff --git a/LICENSE b/LICENSE index 8278472e5..91da68a87 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2010-2016 Google, Inc. +Copyright (c) 2010-2017 Google, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index bceb19cf1..a16b88c54 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,23 @@ -Protractor [![Build Status](https://travis-ci.org/angular/protractor.png?branch=master)](https://travis-ci.org/angular/protractor) [![Join the chat at https://gitter.im/angular/protractor](https://badges.gitter.im/angular/protractor.svg)](https://gitter.im/angular/protractor) +Protractor [![Build Status](https://travis-ci.org/angular/protractor.svg?branch=master)](https://travis-ci.org/angular/protractor) [![CircleCI Status](https://circleci.com/gh/angular/protractor.svg?style=shield)](https://circleci.com/gh/angular/protractor) [![Join the chat at https://gitter.im/angular/protractor](https://badges.gitter.im/angular/protractor.svg)](https://gitter.im/angular/protractor) ========== -[Protractor](http://angular.github.io/protractor) is an end-to-end test framework for [AngularJS](http://angularjs.org/) applications. Protractor is a [Node.js](http://nodejs.org/) program built on top of [WebDriverJS](https://github.com/SeleniumHQ/selenium/wiki/WebDriverJs). Protractor runs tests against your application running in a real browser, interacting with it as a user would. +[Protractor](http://angular.github.io/protractor) is an end-to-end test framework for [Angular](http://angular.io/) and [AngularJS](http://angularjs.org) applications. Protractor is a [Node.js](http://nodejs.org/) program built on top of [WebDriverJS](https://github.com/SeleniumHQ/selenium/wiki/WebDriverJs). Protractor runs tests against your application running in a real browser, interacting with it as a user would. Compatibility ------------- -Protractor 4 is compatible with nodejs v4 and newer. If you absolutely need to use nodjs at 0.12, use Protractor@2. +Protractor 5 is compatible with nodejs v6 and newer. -Protractor work with Angular versions greater than 1.0.6/1.1.4, and is compatible with Angular 2 applications. Note that for Angular 2 apps, the `binding` and `model` locators are not supported. We recommend using `by.css`. +Protractor works with AngularJS versions greater than 1.0.6/1.1.4, and is compatible with Angular applications. Note that for Angular apps, the `binding` and `model` locators are not supported. We recommend using `by.css`. Getting Started --------------- - -The Protractor documentation for users is located in the [protractor/docs](https://github.com/angular/protractor/tree/master/docs) folder. +See the [Protractor Website](http://www.protractortest.org) for most documentation. To get set up and running quickly: - - The [Protractor Website](http://angular.github.io/protractor) - - Work through the [Tutorial](http://angular.github.io/protractor/#/tutorial) - - Take a look at the [Table of Contents](http://angular.github.io/protractor/#/toc) + - Work through the [Tutorial](http://www.protractortest.org/#/tutorial) + - See the [API](http://www.protractortest.org/#/api) Once you are familiar with the tutorial, you’re ready to move on. To modify your environment, see the Protractor Setup docs. To start writing tests, see the Protractor Tests docs. @@ -36,32 +34,4 @@ Please ask usage and debugging questions on [StackOverflow](http://stackoverflow For Contributors ---------------- -Clone the github repository: - - git clone https://github.com/angular/protractor.git - cd protractor - npm install - ./bin/webdriver-manager update - cd website - npm install - cd .. - -Start up a selenium server. By default, the tests expect the selenium server to be running at `http://localhost:4444/wd/hub`. A selenium server can be started with [webdriver-manager](https://github.com/angular/webdriver-manager) which is included in -[bin/webdriver-manager](https://github.com/angular/protractor/blob/master/bin/webdriver-manager). - - webdriver-manager update - webdriver-manager start - -Protractor's test suite runs against the included test application. - -Install the test application dependencies with: - - npm run install_testapp - -Start that up with - - npm start - -Then run the tests with - - npm test +See [DEVELOPER.md](https://github.com/angular/protractor/blob/master/DEVELOPER.md) diff --git a/bin/elementexplorer.js b/bin/elementexplorer.js deleted file mode 100755 index 069b7552c..000000000 --- a/bin/elementexplorer.js +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env node - -/** - * This is an explorer to help get the right element locators, and test out what - * Protractor commands will do on your site without running a full test suite. - * - * This beta version only uses the Chrome browser. - * - * Usage: - * - * Expects a selenium standalone server to be running at http://localhost:4444 - * from protractor directory, run with: - * - * ./bin/elementexplorer.js - * - * This will load up the URL on webdriver and put the terminal into a REPL loop. - * You will see a > prompt. The `browser`, `element` and `protractor` variables - * will be available. Enter a command such as: - * - * > element(by.id('foobar')).getText() - * - * or - * - * > browser.get('http://www.angularjs.org') - * - * try just - * - * > browser - * - * to get a list of functions you can call. - * - * Typing tab at a blank prompt will fill in a suggestion for finding - * elements. - */ -console.log('Please use "protractor [configFile] [options] --elementExplorer"' + - ' for full functionality\n'); - -if (process.argv.length > 3) { - console.log('usage: elementexplorer.js [url]'); - process.exit(1); -} else if (process.argv.length === 3) { - process.argv[2] = ('--baseUrl=' + process.argv[2]); -} - -process.argv.push('--elementExplorer'); -require('../built/cli.js'); diff --git a/bin/webdriver-manager b/bin/webdriver-manager index 1792e6e59..3f8533a21 100755 --- a/bin/webdriver-manager +++ b/bin/webdriver-manager @@ -1,3 +1,3 @@ #!/usr/bin/env node -require('webdriver-manager'); +require('webdriver-manager/dist/lib/cli'); diff --git a/debugging/async_await.js b/debugging/async_await.js new file mode 100644 index 000000000..8ba3fbb4e --- /dev/null +++ b/debugging/async_await.js @@ -0,0 +1,37 @@ +describe('angularjs homepage', function() { + it('should greet the named user', async function() { + debugger; + await browser.get('http://www.angularjs.org'); + + await element(by.model('yourName')).sendKeys('Julie'); + + var greeting = element(by.binding('yourName')); + + expect(await greeting.getText()).toEqual('Hello Julie!'); + }); + + describe('todo list', function() { + var todoList; + + beforeEach(async function() { + await browser.get('http://www.angularjs.org'); + todoList = element.all(by.repeater('todo in todoList.todos')); + }); + + it('should list todos', async function() { + expect(await todoList.count()).toEqual(2); + expect(await todoList.get(1).getText()).toEqual('build an AngularJS app'); + }); + + it('should add a todo', async function() { + var addTodo = element(by.model('todoList.todoText')); + var addButton = element(by.css('[value="add"]')); + + await addTodo.sendKeys('write a protractor test'); + await addButton.click(); + + expect(await todoList.count()).toEqual(3); + expect(await todoList.get(2).getText()).toEqual('write a protractor test'); + }); + }); +}); diff --git a/debugging/conf.js b/debugging/conf.js new file mode 100644 index 000000000..78b09d08f --- /dev/null +++ b/debugging/conf.js @@ -0,0 +1,23 @@ +// An example configuration file for debugging test using async/await. +exports.config = { + // Capabilities to be passed to the webdriver instance. + capabilities: { + 'browserName': 'chrome' + }, + + seleniumAddress: 'http://localhost:4444/wd/hub', + + // Framework to use. Jasmine is recommended. + framework: 'jasmine', + + // Spec patterns are relative to the current working directory when + // protractor is called. + specs: ['async_await.js'], + + SELENIUM_PROMISE_MANAGER: false, + + // Options to be passed to Jasmine. + jasmineNodeOpts: { + defaultTimeoutInterval: 30000 + } +}; diff --git a/docs/api-overview.md b/docs/api-overview.md index d05e35f1b..37dc897b3 100644 --- a/docs/api-overview.md +++ b/docs/api-overview.md @@ -1,7 +1,7 @@ Working with Spec and Config Files ================================== -Protractor needs two files to run, the test or spec file, and the configuration file. +Protractor needs two files to run: the test or spec file and the configuration file. Spec files ========== @@ -10,7 +10,7 @@ Protractor tests are written using the syntax of your test framework, for examp Example Spec File ----------------- -This simple script ([example_spec.js](/example/example_spec.js)) tests the 'The Basics' example on the [angularjs.org](http://www.angularjs.org) homepage. +This simple script ([example_spec.js](/example/example_spec.js)) tests the 'The Basics' example on the [angularjs.org](http://www.angularjs.org) homepage: ```js describe('angularjs homepage', function() { @@ -42,7 +42,7 @@ Protractor exports these global variables to your spec (test) file: - `browser` - A wrapper around an instance of WebDriver, used for navigation and page-wide information. The `browser.get` method loads a page. Protractor expects Angular to be present on a page, so it will throw an error if the page it is attempting to load does not contain the Angular library. (If you need to interact with a non-Angular page, you may access the wrapped webdriver instance directly with `browser.driver`). - - `element` - A helper function for finding and interacting with DOM elements on the page you are testing. The `element` function searches for an element on the page. It requires one parameter, a locator strategy for locating the element. See [Using Locators](/docs/locators.md) for more information. See Protractor's findelements test suite ([elements_spec.js](/spec/basic/elements_spec.js)) for more examples. + - `element` - A helper function for finding and interacting with DOM elements on the page you are testing. The `element` function searches for an element on the page. It requires one parameter, a locator strategy for locating the element. See [Using Locators](/docs/locators.md) for more information. See Protractor's ElementFinder test suite ([elements_spec.js](/spec/basic/elements_spec.js)) for more examples. - `by` - A collection of element locator strategies. For example, elements can be found by CSS selector, by ID, or by the attribute they are bound to with ng-model. See [Using Locators](/docs/locators.md). @@ -57,7 +57,8 @@ The configuration file tells Protractor how to set up the Selenium Server, which Example Config File ------------------- -A simple configuration ([conf.js](https://github.com/angular/protractor/tree/master/example)) is shown below. +A simple configuration ([conf.js](/example/conf.js)) is shown below: + ```js // An example configuration file exports.config = { @@ -66,7 +67,7 @@ exports.config = { // Capabilities to be passed to the webdriver instance. capabilities: { - 'browserName': 'chrome' + browserName: 'chrome' }, // Spec patterns are relative to the configuration file location passed @@ -84,7 +85,7 @@ exports.config = { Config File ----------- -The [config file](/lib/config.ts) file provides explanations for all of the Protractor configuration options. Default settings include the standalone Selenium Server, the Chrome browser, and the Jasmine test framework. Additional information about various configuration options is available here: +The [config file](/lib/config.ts) provides explanations for all of the Protractor configuration options. Default settings include the standalone Selenium Server, the Chrome browser, and the Jasmine test framework. Additional information about various configuration options is available here: - [Setting Up the Selenium Server](/docs/server-setup.md) - [Setting Up the Browser](/docs/browser-setup.md) diff --git a/docs/async-await.md b/docs/async-await.md new file mode 100644 index 000000000..ed3b57a5d --- /dev/null +++ b/docs/async-await.md @@ -0,0 +1,84 @@ +`async`/`await` +=============== + +**Background** + +- The Web Driver Control Flow is used to synchronize your commands so they reach +the browser in the correct order (see +[/docs/control-flow.md](/docs/control-flow.md) for details). In the future, the +control flow is being removed (see [SeleniumHQ's github issue]( +https://github.com/SeleniumHQ/selenium/issues/2969) for details). Instead of the +control flow, you can synchronize your commands with promise chaining or the +upcoming ES7 feature `async`/`await`. + +- Previously, we have Typescript support for `async`/`await`: Please see [TypeScript examples which use `async`/`await`](/exampleTypescript/asyncAwait/README.md). + +- The latest [Node.js](https://nodejs.org/en/) provides native async/await, + which means we can get stable e2e test without using control flow in javascript test. + + **Note**: To write and run native async/await test, the node.js version should be greater than or equal to 8.0, and Jasmine version should be greater than or equal to 2.7 + +- If we disable control flow and use async/await to write tests, we can get a + better debugging experience by using [chrome + inspector](/docs/debugging.md#disabled-control-flow) + +**How to use native async/await in test** + +We have a simple example to show how to use async/await in test. + +You can find the whole example in +[here](/debugging/async_await.js) + +```javascript +describe('angularjs homepage', function() { + it('should greet the named user', async function() { + await browser.get('http://www.angularjs.org'); + + await element(by.model('yourName')).sendKeys('Julie'); + + var greeting = element(by.binding('yourName')); + + expect(await greeting.getText()).toEqual('Hello Julie!'); + }); +``` + +As you can see, the syntax is almost the same with TypeScript async/await. + +1. We need wrap our asynchronous function with “async”. +1. We can add “await” keyword to each operation that we want our program to + wait for. + + **Note:** Never forget to add “await” keyword in an async function, it + may bring some unexpected problem (e.g. your test might fail silently and + always be reported as passed). +1. Don’t forget to turn off control_flow, you cannot use a mix of `async`/`await` and the control flow: +`async`/`await` causes the control flow to become unreliable (see +[github issue]( https://github.com/SeleniumHQ/selenium/issues/3037)). So if you +`async`/`await` anywhere in a spec, you should use the +`SELENIUM_PROMISE_MANAGER: false` + +```javascript +// An example configuration file for debugging test using async/await. +exports.config = { + // Capabilities to be passed to the webdriver instance. + capabilities: { + 'browserName': 'chrome' + }, + + seleniumAddress: 'http://localhost:4444/wd/hub', + + // Framework to use. Jasmine is recommended. + framework: 'jasmine', + + // Spec patterns are relative to the current working directory when + // protractor is called. + specs: ['async_await.js'], + + SELENIUM_PROMISE_MANAGER: false, + + // Options to be passed to Jasmine. + jasmineNodeOpts: { + defaultTimeoutInterval: 30000 + } +}; +``` diff --git a/docs/breakpoint.png b/docs/breakpoint.png new file mode 100644 index 000000000..704cae7be Binary files /dev/null and b/docs/breakpoint.png differ diff --git a/docs/browser-setup.md b/docs/browser-setup.md index 0e429deda..e0afb9511 100644 --- a/docs/browser-setup.md +++ b/docs/browser-setup.md @@ -43,17 +43,30 @@ You may need to install a separate binary to run another browser, such as IE or Adding Chrome-Specific Options ------------------------------ -Chrome options are nested in the `chromeOptions` object. A full list of options is at the [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/capabilities) site. For example, to show an FPS counter in the upper right, your configuration would look like this: +Chrome options are nested in the `goog:chromeOptions` object. A full list of options is at the [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/capabilities) site. For example, to show an FPS counter in the upper right, your configuration would look like this: ```javascript capabilities: { 'browserName': 'chrome', - 'chromeOptions': { + 'goog:chromeOptions': { 'args': ['show-fps-counter=true'] } }, ``` +Adding Firefox-Specific Options +------------------------------ + +Firefox options are nested in the `moz:firefoxOptions` object. A full list of options is at the [GeckoDriver](https://github.com/mozilla/geckodriver#firefox-capabilities) Github page. For example, to run in safe mode, your configuration would look like this: + +```javascript +capabilities: { + 'browserName': 'firefox', + 'moz:firefoxOptions': { + 'args': ['--safe-mode'] + } +}, +``` Testing Against Multiple Browsers --------------------------------- @@ -118,25 +131,40 @@ browser2.$('.css').click(); Setting up PhantomJS -------------------- -_Note: We recommend against using PhantomJS for tests with Protractor. There are many reported issues with PhantomJS crashing and behaving differently from real browsers._ +PhantomJS is [no longer officially supported](https://groups.google.com/forum/#!topic/phantomjs/9aI5d-LDuNE). Instead, we recommend to use one of the following alternatives: +1. Chrome with [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome). Available in Chrome 59+ on Linux/Mac OS X, and in Chrome 60+ on Windows. +2. Firefox with [headless mode](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#-headless). Available in Firefox 55+ on Linux, and in Firefox 56+ on Windows/Mac OS X. +3. Chrome with [Xvfb](http://www.tothenew.com/blog/protractor-with-jenkins-and-headless-chrome-xvfb-setup/). + -In order to test locally with [PhantomJS](http://phantomjs.org/), you'll need to either have it installed globally, or relative to your project. For global install see the [PhantomJS download page](http://phantomjs.org/download.html). For local install run: `npm install phantomjs`. +Using headless Chrome +--------------------- +To start Chrome in headless mode, start Chrome with the `--headless` flag. + +As of Chrome 58 you also need to set `--disable-gpu`, though this may change in future versions. +Also, changing the window size during a test will not work in headless mode, but you can set it +on the commandline like this `--window-size=800,600`. -Add phantomjs to the driver capabilities, and include a path to the binary if using local installation: ```javascript capabilities: { - 'browserName': 'phantomjs', + browserName: 'chrome', + + 'goog:chromeOptions': { + args: [ "--headless", "--disable-gpu", "--window-size=800,600" ] + } +} +``` - /* - * Can be used to specify the phantomjs binary path. - * This can generally be ommitted if you installed phantomjs globally. - */ - 'phantomjs.binary.path': require('phantomjs').path, +Using headless Firefox +--------------------- +To start Firefox in headless mode, start Firefox with the [`--headless` flag](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#-headless). + +```javascript +capabilities: { + browserName: 'firefox', - /* - * Command line args to pass to ghostdriver, phantomjs's browser driver. - * See https://github.com/detro/ghostdriver#faq - */ - 'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG'] + 'moz:firefoxOptions': { + args: [ "--headless" ] + } } ``` diff --git a/docs/chromeDevTool.png b/docs/chromeDevTool.png new file mode 100644 index 000000000..79c4b3993 Binary files /dev/null and b/docs/chromeDevTool.png differ diff --git a/docs/control-flow.md b/docs/control-flow.md index 4d8c9e65e..bf82f0c38 100644 --- a/docs/control-flow.md +++ b/docs/control-flow.md @@ -6,6 +6,22 @@ which are managed by a [control flow](https://github.com/SeleniumHQ/selenium/wik and adapted for [Jasmine](http://jasmine.github.io/2.3/introduction.html). A short summary about how Protractor interacts with the control flow is presented below. +Disabling the Control Flow +-------------------------- + +In the future, the control flow is being removed (see +[SeleniumHQ's github issue](https://github.com/SeleniumHQ/selenium/issues/2969) +for details). To disable the control flow in your tests, you can use the +`SELENIUM_PROMISE_MANAGER: false` [config option](/lib/config.ts#L714). + +Instead of the control flow, you can synchronize your commands +with promise chaining or the upcoming ES7 feature `async`/`await`. See +[`/spec/ts/`](/spec/ts/) for examples of tests with the control flow disabled. + +Because `async`/`await` uses native promises, it will make the Control Flow +unreliable. As such, if you're writing a library or plugin which needs to work +whether or not the Control Flow is enabled, you'll need to handle +synchronization using promise chaining. Promises and the Control Flow ----------------------------- diff --git a/docs/debugging.md b/docs/debugging.md index 93165aa83..3be69ef65 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -7,8 +7,7 @@ state of the application they're testing. WebDriver tests in particular can be difficult to debug because of long error messages and the separation between the browser and the process running the test. -Types of Failure ----------------- +## Types of Failure Protractor comes with examples of failing tests ([failure_spec.js](https://github.com/angular/protractor/blob/master/debugging/failure_spec.js)). To run, start up the test application and a Selenium Server, and run the command below. Then look at all the stack traces. @@ -28,15 +27,125 @@ This test suite shows various types of failure: like. -Timeouts --------- +## Timeouts There are several ways that Protractor can time out. See the [Timeouts](/docs/timeouts.md) reference for full documentation. +## Disabled Control Flow -Pausing to Debug ----------------- + +The latest [Node.js](https://nodejs.org/en/) provides native async/await, which +means we can get stable e2e test easily without using control flow. Furthermore, +if we write our test by using async/await[(how to?)](/docs/async-await.md), we can +use chrome development tool and chrome inspector together to debug the new +tests, which will give a nicer debugging experience. + +**Debuging tests in chrome inspector** + +We can debug both javascript and TypeScript async/await tests in chrome +inspector and the debugging process is almost the same. + +We have a simple example to show how to debug async/await in test. You can find +the whole example in +[here](/debugging/async_await.js) + +- Add “debugger” keyword to the test case that we want to debug. + + ```javascript + it('should greet the named user', async function() { + debugger; + await browser.get('http://www.angularjs.org'); + + await element(by.model('yourName')).sendKeys('Julie'); + + var greeting = element(by.binding('yourName')); + + expect(await greeting.getText()).toEqual('Hello Julie!'); + }); + ``` + +- Start test process with a new argument "inspect-brk", which will enable + inspector agent, listen on default address and port (127.0.0.1:9229) and + break before user code starts + + Use + + ``` + node --inspect-brk bin/protractor + ``` + +- Open chrome inspector: Enter "chrome://inspect/#devices" in browser, find + the current running target and click “Inspect” + + ![screenshot](/docs/inspector.png) + +- The test will start and pause at the beginning. + + ![screenshot](/docs/firstBreak.png) + +- We can click F8 (resume script execution), and the test will pause at the + first line that has our “debugger” keyword. We can then add breakpoints and + debug tests. + + ![screenshot](/docs/breakpoint.png) + +- We can also open chrome development tool on the webdriver controlled browser + to check the html elements and do some queries while the test execution is + pausing. + + ![screenshot](/docs/chromeDevTool.png) + +- Known Issues + +1. If we resume test execution after a long time pause, it will jump to next + test case even we have some other breaking points in current test case since + current test case has already been timeout. You can set + jasmine.DEFAULT_TIMEOUT_INTERVAL to an arbitrary high value so that your + test doesn't time out. + +2. If we step into protractor lib code which was written in Typescript, we + cannot see the TypeScript code. In general, you can add breakpoints to each + line that you want it to pause, and use F8 (resume script execution) to + debug(To avoid step into protractor lib). + + +**Setting Up VSCode for Debugging** + +VS Code has built-in [debugging](https://code.visualstudio.com/docs/editor/debugging) support for the Node.js runtime and can debug JavaScript, TypeScript, and any other language that gets transpiled to JavaScript. + +To set up VSCode for Protractor, follow the below steps: + +1. Click on the Debugging icon in the View Bar on the side of VS Code. +2. Click on the Configure gear icon on the Debug view top bar and choose nodejs environment. +3. It will generate a `launch.json` file under your workspace's `.vscode` folder. +4. Setup your launch.json file by configuring below two commands: +``` + "program": "${workspaceRoot}/node_modules/protractor/bin/protractor", + "args": ["${workspaceRoot}/protractorConfig.js"], +``` +5. Save your launch.json, put some breakpoints and start debugging. + +**Setting Up WebStorm for Debugging** + +To set up WebStorm for Protractor, do the following: + +1. Open the Run/Debug Configurations dialog +2. Add new Node.js configuration. +3. On the Configuration tab set: + - **Node Interpreter**: path to node executable + - **Working directory**: your project base path + - **JavaScript file**: path to Protractor cli.js file (e.g. *node_modules\protractor\built\cli.js*) + - **Application parameters**: path to your Protractor configuration file (e.g. + *protractorConfig.js*) +4. Click OK, place some breakpoints, and start debugging. + + +## Enabled Control Flow + +**Note:** Protractor debugger and element explorer cannot be used for Node.js 8+ + +**Pausing to Debug** Protractor supports two methods for pausing to debug - `browser.pause()` and `browser.debugger()`. You probably want to use `browser.pause()`, unless you @@ -76,7 +185,16 @@ wd-debug> ``` Enter `c` to move the test forward by one task. -Enter `repl` to enter interactive mode. In interactive mode, you can send + +While the test is paused you may also interact with the browser. Note that +if you open the Chrome Dev Tools, you must close them before continuing +the test because ChromeDriver cannot operate when the Dev Tools are open. + +When you finish debugging, exit by pressing `Ctrl-C`. Your tests will continue +where they left off, using the same browser. + +You can also use `browser.explore()` in your test script to pause and enter +an interactive repl loop. In this interactive mode, you can send WebDriver commands to your browser. The resulting value or error will be reported to the terminal. @@ -88,13 +206,6 @@ NoSuchElementError: No element found using locator: by.binding("nopenopenope") 'Anon' ``` -While the test is paused you may also interact with the browser. Note that -if you open the Chrome Dev Tools, you must close them before continuing -the test because ChromeDriver cannot operate when the Dev Tools are open. - -When you finish debugging, exit by pressing `Ctrl-C`. Your tests will continue -where they left off, using the same browser. - **Note:** Since these are asynchronous tasks, you would have to increase the default timeout of your specs else default timeout exception would be thrown! **Using debugger** @@ -146,40 +257,8 @@ used from the browser's console. // You can also limit the scope of the locator > window.clientSideScripts.findInputs('username', document.getElementById('#myEl')); ``` -Setting Up VSCode for Debugging -------------------------------- -VS Code has built-in [debugging](https://code.visualstudio.com/docs/editor/debugging) support for the Node.js runtime and can debug JavaScript, TypeScript, and any other language that gets transpiled to JavaScript. - -To set up VSCode for Protractor, follow the below steps: - -1. Click on the Debugging icon in the View Bar on the side of VS Code. -2. Click on the Configure gear icon on the Debug view top bar and choose nodejs environment. -3. It will generate a `launch.json` file under your workspace's `.vscode` folder. -4. Setup your launch.json file by configuring below two commands: -``` - "program": "${workspaceRoot}/node_modules/protractor/bin/protractor", - "args": ["${workspaceRoot}/protractorConfig.js"], -``` -5. Save your launch.json, put some breakpoints and start debugging. - -Setting Up WebStorm for Debugging ---------------------------------- - -To set up WebStorm for Protractor, do the following: - -1. Open the Run/Debug Configurations dialog -2. Add new Node.js configuration. -3. On the Configuration tab set: - - **Node Interpreter**: path to node executable - - **Working directory**: your project base path - - **JavaScript file**: path to Protractor cli.js file (e.g. *node_modules\protractor\lib\cli.js*) - - **Application parameters**: path to your Protractor configuration file (e.g. - *protractorConfig.js*) -4. Click OK, place some breakpoints, and start debugging. - -Testing Out Protractor Interactively ------------------------------------- +**Testing Out Protractor Interactively** When debugging or first writing test suites, you may find it helpful to try out Protractor commands without starting up the entire test suite. You can @@ -206,8 +285,8 @@ matching a locator. Element explorer will start chrome by default. However, you can specify another browser, change browser settings, or specify any other config that you -normally would with your protractor test. To do this, pass configs to -protractor like you normally would, +normally would with your protractor test. To do this, pass configs to +protractor like you normally would, but with the `--elementExplorer` flag set: protractor [configFile] [options] --elementExplorer @@ -216,16 +295,15 @@ For example, to connect to ChromeDriver directly, use protractor --directConnect --elementExplorer -Element explore will ignore your specs, not set up your framework (e.g. jasmine, +Element explore will ignore your specs, not set up your framework (e.g. jasmine, mocha, cucumber), and only allow you to pass in 1 capability, but will honor every other parameter in your config. -Note `baseUrl` is used here as the initial page, i.e. element explorer will try +Note `baseUrl` is used here as the initial page, i.e. element explorer will try to navigate to `baseUrl` automatically on start. -Taking Screenshots ------------------- +## Taking Screenshots WebDriver can snap a screenshot with `browser.takeScreenshot()`. This can be a good way to help debug tests, especially for tests that run on a continuous integration diff --git a/docs/faq.md b/docs/faq.md index fd4b7c130..8e51c3df7 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -11,12 +11,12 @@ What's the difference between Karma and Protractor? When do I use which? --------------------------------------------------- [Karma](http://karma-runner.github.io) is a great tool for unit testing, and Protractor is intended for -end to end or integration testing. This means that small tests for the logic +end-to-end or integration testing. This means that small tests for the logic of your individual controllers, directives, and services should be run using Karma. Big tests in which you have a running instance of your entire application should be run using Protractor. Protractor is intended to run tests from a user's point of view - if your test could be written down as instructions -for a human interacting with your application, it should be an end to end test +for a human interacting with your application, it should be an end-to-end test written with Protractor. Here's a [great blog post](http://www.yearofmoo.com/2013/09/advanced-testing-and-debugging-in-angularjs.html) @@ -25,18 +25,21 @@ with more info. Angular can't be found on my page --------------------------------- -Protractor supports angular 1.0.6/1.1.4 and higher - check that your version of Angular is upgraded. +Protractor supports Angular and AngularJS 1.0.6/1.1.4 and higher - check that your version of Angular is upgraded. -The `angular` variable is expected to be available in the global context. Try opening chrome devtools or firefox and see if `angular` is defined. +For AngularJS apps, the `angular` variable is expected to be available in the global context. Try opening chrome devtools or firefox and see if `angular` is defined. + +For Angular apps, you should see a global method `getAllAngularTestabilities`. How do I deal with my log-in page? ---------------------------------- If your app needs log-in, there are a couple ways to deal with it. If your login page is not written with Angular, you'll need to interact with it via -unwrapped webdriver, which can be accessed like `browser.driver.get()`. +unwrapped webdriver, which can be accessed like `browser.driver.get()`. You can also use +`browser.waitForAngularEnabled(false)` as explained [here](/docs/timeouts.md#how-to-disable-waiting-for-angular). -You can put your log-in code into an `onPrepare` function, which will be run +Another option is to put your log-in code into an `onPrepare` function, which will be run once before any of your tests. See this example ([withLoginConf.js](https://github.com/angular/protractor/blob/master/spec/withLoginConf.js)) Which browsers are supported? @@ -50,6 +53,13 @@ This is a [webdriver quirk](http://grokbase.com/t/gg/webdriver/12bcmvwhcm/extarc `` and `