diff --git a/.github/workflows/Semgrep.yml b/.github/workflows/Semgrep.yml
new file mode 100644
index 0000000..5398af9
--- /dev/null
+++ b/.github/workflows/Semgrep.yml
@@ -0,0 +1,49 @@
+# Name of this GitHub Actions workflow.
+name: Semgrep
+
+on:
+ # Scan changed files in PRs (diff-aware scanning):
+ # The branches below must be a subset of the branches above
+ pull_request:
+ branches: ["master", "main"]
+ push:
+ branches: ["master", "main"]
+ schedule:
+ - cron: '0 6 * * *'
+
+
+permissions:
+ contents: read
+
+jobs:
+ semgrep:
+ # User definable name of this GitHub Actions job.
+ permissions:
+ contents: read # for actions/checkout to fetch code
+ security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
+ name: semgrep/ci
+ # If you are self-hosting, change the following `runs-on` value:
+ runs-on: ubuntu-latest
+
+ container:
+ # A Docker image with Semgrep installed. Do not change this.
+ image: returntocorp/semgrep
+
+ # Skip any PR created by dependabot to avoid permission issues:
+ if: (github.actor != 'dependabot[bot]')
+
+ steps:
+ # Fetch project source with GitHub Actions Checkout.
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
+ # Run the "semgrep ci" command on the command line of the docker image.
+ - run: semgrep ci --sarif --output=semgrep.sarif
+ env:
+ # Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
+ SEMGREP_RULES: p/default # more at semgrep.dev/explore
+
+ - name: Upload SARIF file for GitHub Advanced Security Dashboard
+ uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
+ with:
+ sarif_file: semgrep.sarif
+ if: always()
+
diff --git a/.github/workflows/reviewing_changes.yml b/.github/workflows/reviewing_changes.yml
new file mode 100644
index 0000000..479879b
--- /dev/null
+++ b/.github/workflows/reviewing_changes.yml
@@ -0,0 +1,88 @@
+# This job is to test different npm profiles in master branch against Pull Request raised
+# This workflow targets nightwatch
+
+name: NodeJS Test workflow on workflow_dispatch
+
+on:
+ workflow_dispatch:
+ inputs:
+ commit_sha:
+ description: 'The full commit id to build'
+ required: true
+
+jobs:
+ comment-run:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ max-parallel: 3
+ matrix:
+ node: ['14', '16', '18']
+ os: [ macos-latest, windows-latest, ubuntu-latest ]
+ name: Nightwatch Appium Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
+ env:
+ BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
+ BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
+
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ ref: ${{ github.event.inputs.commit_sha }}
+ - uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
+ id: status-check-in-progress
+ env:
+ job_name: Nightwatch Appium Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
+ commit_sha: ${{ github.event.inputs.commit_sha }}
+ with:
+ github-token: ${{ github.token }}
+ script: |
+ const result = await github.rest.checks.create({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ name: process.env.job_name,
+ head_sha: process.env.commit_sha,
+ status: 'in_progress'
+ }).catch((err) => ({status: err.status, response: err.response}));
+ console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
+ if (result.status !== 201) {
+ console.log('Failed to create check run')
+ }
+ - name: Setup node
+ uses: actions/setup-node@v3
+ with:
+ node-version: ${{ matrix.node }}
+
+ - name: Install dependencies
+ run: npm install
+
+ - name: Run sample android tests
+ run: npm run single-android
+
+ - name: Run sample ios tests
+ run: npm run single-ios
+
+ - name: Run local tests
+ run: npm run local
+
+ - if: always()
+ uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
+ id: status-check-completed
+ env:
+ conclusion: ${{ job.status }}
+ job_name: Nightwatch Appium Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
+ commit_sha: ${{ github.event.inputs.commit_sha }}
+ with:
+ github-token: ${{ github.token }}
+ script: |
+ const result = await github.rest.checks.create({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ name: process.env.job_name,
+ head_sha: process.env.commit_sha,
+ status: 'completed',
+ conclusion: process.env.conclusion
+ }).catch((err) => ({status: err.status, response: err.response}));
+ console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
+ if (result.status !== 201) {
+ console.log('Failed to create check run')
+ }
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2d9e04c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,127 @@
+.idea
+allure-report/
+results/
+
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+local.log
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+*.lcov
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# Snowpack dependency directory (https://snowpack.dev/)
+web_modules/
+
+# TypeScript cache
+*.tsbuildinfo
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Microbundle cache
+.rpt2_cache/
+.rts2_cache_cjs/
+.rts2_cache_es/
+.rts2_cache_umd/
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+.env.test
+
+# parcel-bundler cache (https://parceljs.org/)
+.cache
+.parcel-cache
+
+# Next.js build output
+.next
+out
+
+# Nuxt.js build / generate output
+.nuxt
+dist
+
+# Gatsby files
+.cache/
+# Comment in the public line in if your project uses Gatsby and not Next.js
+# https://nextjs.org/blog/next-9-1#public-directory-support
+# public
+
+# vuepress build output
+.vuepress/dist
+
+# Serverless directories
+.serverless/
+
+# FuseBox cache
+.fusebox/
+
+# DynamoDB Local files
+.dynamodb/
+
+# TernJS port file
+.tern-port
+
+# DS_Store
+.DS_Store
+
+# Stores VSCode versions used for testing VSCode extensions
+.vscode-test
+
+# yarn v2
+.yarn/cache
+.yarn/unplugged
+.yarn/build-state.yml
+.yarn/install-state.gz
+.pnp.*
+
+#test-output
+tests_output
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..088dad1
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,10 @@
+language: node_js
+node_js:
+ - "4.3"
+ - "4.0"
+ - "0.12"
+ - "0.10"
+
+before_install:
+ - true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==`
+
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000..352113a
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1 @@
+* @browserstack/app-automate-public-repos
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/README.md b/README.md
index bef09da..79cffef 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,95 @@
# nightwatch-appium-app-browserstack
This repository demonstrates how to run Appium tests in Nightwatch on BrowserStack App Automate.
+
+[Nightwatch](http://nightwatchjs.org/) Integration with BrowserStack.
+
+
+
+## Setup
+
+- Clone the repo
+- Install the dependencies using `npm install`
+- Export the environment variables for the Username and Access Key of your BrowserStack account, which you can get directly from the app automate dashboard
+
+ ```
+ export BROWSERSTACK_USERNAME= &&
+ export BROWSERSTACK_ACCESS_KEY=
+ ```
+
+
+## Running your tests
+
+- To run a single android test, run `npm run single-android`
+- To run a single ios test, run `npm run single-ios`
+- To run local tests, run `npm run local`
+
+Please run the above tests once before running parallel tests, so that the apps can be uploaded on the respective [custom id](https://www.browserstack.com/docs/app-automate/appium/upload-app-define-custom-id).
+- To run parallel tests, run `npm run parallel`
+- To run parallel tests on different devices, run `npm run parallel-devices`
+- To run test suite, run `npm run suite`
+- To run parallel local tests, run `npm run parallel-local`
+
+
+Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
+
+## Notes
+
+- You can view your test results on the [BrowserStack app automate dashboard](https://app-automate.browserstack.com/)
+- To test on a different set of browsers, check out our [capabilities generator](https://www.browserstack.com/app-automate/capabilities)
+
+
+## Connecting to BrowserStack via a proxy server
+
+You can specify proxy settings in Nightwatch by adding the `proxy` key in your `*.conf.js`
+
+```javascript
+ test_settings: {
+ default: {
+ desiredCapabilities: {
+ // Your capabilities
+ },
+ proxy: {
+ "host": "", // "127.0.0.1"
+ "port": "", // "8081"
+ "protocol": "" // "http"
+ }
+ }
+ }
+```
+
+## Browserstack Test Observability
+
+Test Observability is a reporting tool that helps you isolate the genuine test failures after eliminating noise from flaky and always failing tests and also helps with root cause analysis of failed tests.
+
+With Test Observability, you can not only complete your run verification in minutes, you will also be empowered with rich historical data to understand the overall health of your test suites, uncover burning issues impacting the stability of your tests, and help you optimize your tests.
+
+You can learn more about [what the product has to offer and why you should be using it](https://www.browserstack.com/docs/test-observability/overview/what-is-test-observability).
+
+Please add the following code snippet to your **nightwatch.conf.js**.
+```js
+ module.exports = {
+ //...
+plugins: ['@nightwatch/browserstack'],
+'@nightwatch/browserstack': {
+ test_observability: {
+ enabled: true,
+ user: process.env.BROWSERSTACK_USERNAME,
+ key: process.env.BROWSERSTACK_ACCESS_KEY,
+ projectName: "Enter Static Project Name Here",
+ buildName: "Enter Static Project Name Here",
+ buildTag: ["Custom Tag 1","Custom Tag 2"]
+ }
+
+ },
+ //...
+ };
+```
+To get started with the Test Observability integration with your Nightwatch Project, please refer to this [documentation](https://www.browserstack.com/docs/test-observability/quick-start/nightwatch).
+
+## Additional Resources
+
+- [Documentation for writing app automate test scripts in Node](https://www.browserstack.com/docs/app-automate/appium/getting-started/nodejs)
+- [Customizing your tests on BrowserStack](https://www.browserstack.com/app-automate/capabilities)
+- [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms/app_automate)
+- [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/docs/app-automate/api-reference/introduction)
+
diff --git a/apps/android_app.apk b/apps/android_app.apk
new file mode 100644
index 0000000..7252dc6
Binary files /dev/null and b/apps/android_app.apk differ
diff --git a/apps/android_local_app.apk b/apps/android_local_app.apk
new file mode 100644
index 0000000..f31c574
Binary files /dev/null and b/apps/android_local_app.apk differ
diff --git a/apps/ios_app.ipa b/apps/ios_app.ipa
new file mode 100644
index 0000000..c1891b8
Binary files /dev/null and b/apps/ios_app.ipa differ
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..9bf35ea
--- /dev/null
+++ b/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "nightwatch-browserstack",
+ "version": "1.0.0",
+ "readme": "Nightwatch Integration with [BrowserStack](https://www.browserstack.com)",
+ "description": "Selenium examples for Nightwatch and BrowserStack Automate",
+ "scripts": {
+ "test": "npm run single-android && npm run local && npm run parallel",
+ "single-android": "nightwatch --test ./tests/specs/e2e/*.js --config ./resources/config/nightwatch.conf.js --env browserstack.android_01",
+ "single-ios": "nightwatch --test ./tests/single/single_ios.js --config ./resources/config/nightwatch.conf.js --env browserstack.ios_01",
+ "local": "nightwatch --config ./resources/config/nightwatch-local.conf.js --test ./tests/local/local_test.js --env browserstack.local_01 ",
+ "parallel": "nightwatch --config ./resources/config/nightwatch-suite.conf.js --parallel --env browserstack.android_01",
+ "parallel-devices": "nightwatch --config ./resources/config/nightwatch-suite.conf.js --parallel --env browserstack.android_01,browserstack.android_02",
+ "parallel-local": "nightwatch --config ./resources/config/nightwatch-local.conf.js --test ./tests/local/local_test.js --parallel --env browserstack.local_01,browserstack.local_02",
+ "suite": "nightwatch --config ./resources/config/nightwatch-suite.conf.js --env browserstack.android_01"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/browserstack/nightwatch-appium-app-browserstack"
+ },
+ "dependencies": {
+ "browserstack-local": "^1.4.8",
+ "nightwatch": "^2.6.21"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "@nightwatch/browserstack": "^0.2.1"
+ }
+}
diff --git a/resources/config/environments.js b/resources/config/environments.js
new file mode 100644
index 0000000..3d65807
--- /dev/null
+++ b/resources/config/environments.js
@@ -0,0 +1,11 @@
+const common_capabilities = {
+ 'buildName': 'browserstack-build-1',
+ 'userName': '${BROWSERSTACK_USERNAME}',
+ 'accessKey': '${BROWSERSTACK_ACCESS_KEY}',
+ 'debug': true
+};
+module.exports = {
+ test_settings: {
+ default: {},
+ }
+};
diff --git a/resources/config/nightwatch-local.conf.js b/resources/config/nightwatch-local.conf.js
new file mode 100644
index 0000000..4a47f8d
--- /dev/null
+++ b/resources/config/nightwatch-local.conf.js
@@ -0,0 +1,89 @@
+const additonalEnvironments = require("./environments");
+
+if(!additonalEnvironments.test_settings)
+ additonalEnvironments.test_settings = {};
+
+const browserStack = {
+ webdriver: {
+ start_process: false
+ },
+
+ selenium: {
+ host: 'hub.browserstack.com',
+ port: 443
+ },
+ desiredCapabilities: {
+ 'bstack:options': {
+ userName: process.env.BROWSERSTACK_USERNAME,
+ accessKey: process.env.BROWSERSTACK_ACCESS_KEY,
+ appiumVersion: '1.22.0',
+
+ }
+ },
+}
+
+const nightwatchConfigs = {
+ src_folders: [],
+ live_output: true,
+ plugins: ['@nightwatch/browserstack'],
+
+ // browserstack plugin settings...
+ '@nightwatch/browserstack': {
+ browserstackLocal: true, // set true to manage browserstack local tunnel. Defaults to false.
+ test_observability: {
+ enabled: true,
+ user: process.env.BROWSERSTACK_USERNAME,
+ key: process.env.BROWSERSTACK_ACCESS_KEY,
+ projectName: "browserstack-appium-nightwatch-example-project",
+ buildName: "browserstack-appium-nightwatch-example-build",
+ }
+
+ },
+
+ test_settings: {
+ default: {
+ launch_url: 'https://nightwatchjs.org'
+ },
+
+ browserstack: {
+ ...browserStack
+ },
+
+ "browserstack.local_01": {
+ extends: 'browserstack',
+ 'desiredCapabilities': {
+ browserName: null,
+ 'appium:options': {
+ automationName: 'UiAutomator2',
+ // custom id for the uploaded app: https://www.browserstack.com/docs/app-automate/appium/upload-app-define-custom-id
+ app: 'bs_sample_android_local_app',
+ platformVersion: '9.0',
+ deviceName: 'Google Pixel 3'
+ },
+ appUploadPath: 'apps/android_local_app.apk'
+ }
+ },
+ "browserstack.local_02": {
+ extends: 'browserstack',
+ 'desiredCapabilities': {
+ browserName: null,
+ 'appium:options': {
+ automationName: 'UiAutomator2',
+ // custom id for the uploaded app: https://www.browserstack.com/docs/app-automate/appium/upload-app-define-custom-id
+ app: 'bs_sample_android_local_app',
+ platformVersion: '9.0',
+ deviceName: 'Samsung Galaxy S10'
+ }
+ }
+ },
+ }
+}
+
+for(let key in additonalEnvironments.test_settings) {
+ nightwatchConfigs.test_settings[key] = {
+ ...browserStack,
+ ...additonalEnvironments.test_settings[key]
+ };
+}
+
+module.exports = nightwatchConfigs;
diff --git a/resources/config/nightwatch-suite.conf.js b/resources/config/nightwatch-suite.conf.js
new file mode 100644
index 0000000..e42ddbc
--- /dev/null
+++ b/resources/config/nightwatch-suite.conf.js
@@ -0,0 +1,94 @@
+const additonalEnvironments = require("./environments");
+
+if(!additonalEnvironments.test_settings)
+ additonalEnvironments.test_settings = {};
+
+const browserStack = {
+ webdriver: {
+ start_process: false
+ },
+
+ selenium: {
+ host: 'hub.browserstack.com',
+ port: 443
+ },
+ desiredCapabilities: {
+ 'bstack:options': {
+ userName: process.env.BROWSERSTACK_USERNAME,
+ accessKey: process.env.BROWSERSTACK_ACCESS_KEY,
+ appiumVersion: '1.22.0',
+ }
+ },
+}
+
+const nightwatchConfigs = {
+ src_folders: ["./tests/specs/e2e/e2e.spec.js",
+ "./tests/specs/login/*.spec.js",
+ "./tests/specs/offers/*.spec.js",
+ "./tests/specs/user/*.spec.js",
+ "./tests/specs/cart/*.spec.js",],
+ live_output: true,
+ plugins: ['@nightwatch/browserstack'],
+
+ // browserstack plugin settings...
+ '@nightwatch/browserstack': {
+ browserstackLocal: false, // set true to manage browserstack local tunnel. Defaults to false.
+ test_observability: {
+ enabled: true,
+ user: process.env.BROWSERSTACK_USERNAME,
+ key: process.env.BROWSERSTACK_ACCESS_KEY,
+ projectName: "browserstack-appium-nightwatch-example-project",
+ buildName: "browserstack-appium-nightwatch-example-build",
+ }
+
+ },
+
+ test_settings: {
+ default: {
+ launch_url: 'https://nightwatchjs.org'
+ },
+
+ browserstack: {
+ ...browserStack
+ },
+
+
+
+ "browserstack.android_01": {
+ extends: 'browserstack',
+ 'desiredCapabilities': {
+ browserName: null,
+ 'appium:options': {
+ automationName: 'UiAutomator2',
+ // custom id for the uploaded app: https://www.browserstack.com/docs/app-automate/appium/upload-app-define-custom-id
+ app: 'bs_sample_android_app',
+ platformVersion: '11.0',
+ deviceName: 'Google Pixel 5'
+ }
+ }
+ },
+ "browserstack.android_02": {
+ extends: 'browserstack',
+ 'desiredCapabilities': {
+ browserName: null,
+ 'appium:options': {
+ automationName: 'UiAutomator2',
+ // custom id for the uploaded app: https://www.browserstack.com/docs/app-automate/appium/upload-app-define-custom-id
+ app: 'bs_sample_android_app',
+ platformVersion: '11.0',
+ deviceName: 'Google Pixel 4'
+ }
+ }
+ },
+
+ }
+}
+
+for(let key in additonalEnvironments.test_settings) {
+ nightwatchConfigs.test_settings[key] = {
+ ...browserStack,
+ ...additonalEnvironments.test_settings[key]
+ };
+}
+
+module.exports = nightwatchConfigs;
diff --git a/resources/config/nightwatch.conf.js b/resources/config/nightwatch.conf.js
new file mode 100644
index 0000000..3e8b066
--- /dev/null
+++ b/resources/config/nightwatch.conf.js
@@ -0,0 +1,92 @@
+const additonalEnvironments = require("./environments");
+
+if(!additonalEnvironments.test_settings)
+ additonalEnvironments.test_settings = {};
+
+const browserStack = {
+ webdriver: {
+ start_process: false
+ },
+
+ selenium: {
+ host: 'hub.browserstack.com',
+ port: 443
+ },
+ desiredCapabilities: {
+ 'bstack:options': {
+ userName: process.env.BROWSERSTACK_USERNAME,
+ accessKey: process.env.BROWSERSTACK_ACCESS_KEY,
+ appiumVersion: '1.22.0',
+ }
+ },
+}
+
+const nightwatchConfigs = {
+ src_folders: [],
+ live_output: true,
+ plugins: ['@nightwatch/browserstack'],
+
+ // browserstack plugin settings...
+ '@nightwatch/browserstack': {
+ browserstackLocal: false, // set true to manage browserstack local tunnel. Defaults to false.
+ test_observability: {
+ enabled: true,
+ user: process.env.BROWSERSTACK_USERNAME,
+ key: process.env.BROWSERSTACK_ACCESS_KEY,
+ projectName: "browserstack-appium-nightwatch-example-project",
+ buildName: "browserstack-appium-nightwatch-example-build",
+ }
+
+ },
+
+
+
+ test_settings: {
+ default: {
+ launch_url: 'https://nightwatchjs.org'
+ },
+
+ browserstack: {
+ ...browserStack
+ },
+
+ "browserstack.android_01": {
+ extends: 'browserstack',
+ 'desiredCapabilities': {
+ browserName: null,
+ 'appium:options': {
+ automationName: 'UiAutomator2',
+ // custom id for the uploaded app: https://www.browserstack.com/docs/app-automate/appium/upload-app-define-custom-id
+ app: 'bs_sample_android_app',
+ platformVersion: '11.0',
+ deviceName: 'Google Pixel 5'
+ },
+ appUploadPath: 'apps/android_app.apk'
+ }
+ },
+
+ "browserstack.ios_01": {
+ extends: 'browserstack',
+ 'desiredCapabilities': {
+ browserName: null,
+ 'appium:options': {
+ automationName: 'XCUITest',
+ // custom id for the uploaded app: https://www.browserstack.com/docs/app-automate/appium/upload-app-define-custom-id
+ app: 'bs_sample_ios_app',
+ platformVersion: '16',
+ deviceName: 'iPhone 14'
+ },
+ appUploadPath: 'apps/ios_app.ipa'
+ }
+ },
+ }
+}
+
+for(let key in additonalEnvironments.test_settings) {
+ nightwatchConfigs.test_settings[key] = {
+ ...browserStack,
+ ...additonalEnvironments.test_settings[key]
+ };
+}
+
+module.exports = nightwatchConfigs;
diff --git a/resources/data/login_cases.json b/resources/data/login_cases.json
new file mode 100644
index 0000000..a127d00
--- /dev/null
+++ b/resources/data/login_cases.json
@@ -0,0 +1,13 @@
+[
+ {
+ "username": "locked_user",
+ "password": "testingisfun99",
+ "expected_message": "Your account has been locked."
+ },
+ {
+ "username": "fav_user",
+ "password": "wrong_password",
+ "expected_message": "Invalid Password"
+ }
+
+]
diff --git a/resources/data/user.json b/resources/data/user.json
new file mode 100644
index 0000000..888c5b4
--- /dev/null
+++ b/resources/data/user.json
@@ -0,0 +1,18 @@
+[
+ {
+ "username": "fav_user",
+ "password": "testingisfun99"
+ },
+ {
+ "username": "locked_user",
+ "password": "testingisfun99"
+ },
+ {
+ "username": "image_not_loading_user",
+ "password": "testingisfun99"
+ },
+ {
+ "username": "existing_orders_user",
+ "password": "testingisfun99"
+ }
+]
diff --git a/tests/local/local_test.js b/tests/local/local_test.js
new file mode 100644
index 0000000..ecbc1ea
--- /dev/null
+++ b/tests/local/local_test.js
@@ -0,0 +1,13 @@
+
+describe('Local Sample App', function () {
+
+ it('Try Local Testing', async function (app) {
+ app
+ .click('id', 'com.example.android.basicnetworking:id/test_action')
+ .click('id', 'com.example.android.basicnetworking:id/test_action')
+ .assert.elementPresent({ selector: 'com.example.android.basicnetworking:id/textView', locateStrategy: 'id' })
+ .assert.textContains({ selector: 'com.example.android.basicnetworking:id/textView', locateStrategy: 'id'}, 'Up and running')
+ .pause(2000);
+ });
+});
+
diff --git a/tests/pages/cart.page.js b/tests/pages/cart.page.js
new file mode 100644
index 0000000..a4146b0
--- /dev/null
+++ b/tests/pages/cart.page.js
@@ -0,0 +1,11 @@
+const Page = require("./page");
+
+class CartPage extends Page {
+
+ async proceedToCheckout(app) {
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="checkout-btn"]')
+
+ }
+}
+
+module.exports = new CartPage();
diff --git a/tests/pages/checkout.page.js b/tests/pages/checkout.page.js
new file mode 100644
index 0000000..2f99342
--- /dev/null
+++ b/tests/pages/checkout.page.js
@@ -0,0 +1,17 @@
+const Page = require("./page");
+
+class CheckoutPage extends Page {
+
+ async enterShippingDetails(app,firstName, lastName, address, state, postalCode) {
+
+ await app.useXpath().sendKeys('//android.widget.EditText[@content-desc="firstNameInput"]',firstName);
+ await app.useXpath().sendKeys('//android.widget.EditText[@content-desc="lastNameInput"]',lastName);
+ await app.useXpath().sendKeys('//android.widget.EditText[@content-desc="addressInput"]',address);
+ await app.useXpath().sendKeys('//android.widget.EditText[@content-desc="stateInput"]',state);
+ await app.useXpath().sendKeys('//android.widget.EditText[@content-desc="postalCodeInput"]',postalCode);
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="submit-btn"]');
+
+ }
+}
+
+module.exports = new CheckoutPage();
diff --git a/tests/pages/confirmation.page.js b/tests/pages/confirmation.page.js
new file mode 100644
index 0000000..74eb4bf
--- /dev/null
+++ b/tests/pages/confirmation.page.js
@@ -0,0 +1,12 @@
+const Page = require("./page");
+
+class ConfirmationPage extends Page {
+
+
+ async clickContinue(app){
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="continue-btn"]');
+
+ }
+}
+
+module.exports = new ConfirmationPage();
diff --git a/tests/pages/home.page.js b/tests/pages/home.page.js
new file mode 100644
index 0000000..ad79c7b
--- /dev/null
+++ b/tests/pages/home.page.js
@@ -0,0 +1,48 @@
+const Page = require("./page");
+
+class HomePage extends Page {
+
+ async openLoginForm(app) {
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="menu"]/android.view.ViewGroup/android.view.ViewGroup/android.widget.TextView')
+ await app.useXpath().click('//android.widget.TextView[@text="Sign In"]')
+
+ }
+ async openCart(app) {
+
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="nav-cart"]/android.view.ViewGroup/android.view.ViewGroup/android.widget.TextView')
+
+ }
+ async openMenu(app) {
+
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="menu"]/android.view.ViewGroup/android.view.ViewGroup/android.widget.TextView')
+
+ }
+
+ async selectMenuOption(app,option) {
+
+ await app.useXpath().click(`//android.widget.TextView[@text='${option}']`);
+
+ }
+
+ async markProductFavourite(app,product) {
+ await app.useXpath().click(`//android.view.ViewGroup[@content-desc="${product}"]`);
+ }
+
+
+ async logout(app) {
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="nav-logout"]');
+ }
+
+
+ async scrollAndAddToCart(app,product) {
+
+ await app.execute('mobile:scroll', {
+ 'strategy':'accessibility id',
+ 'selector':product
+ });
+
+ await app.useXpath().click(`//android.view.ViewGroup[@content-desc="${product}"]`)
+
+ }
+}
+module.exports = new HomePage();
diff --git a/tests/pages/login.page.js b/tests/pages/login.page.js
new file mode 100644
index 0000000..01004b6
--- /dev/null
+++ b/tests/pages/login.page.js
@@ -0,0 +1,14 @@
+const Page = require("./page");
+
+class LoginPage extends Page {
+
+ async login(app,username, password) {
+ await app.useXpath().click('//android.widget.Spinner[@content-desc="username-input"]');
+ await app.useXpath().click(`//*[@text = '${username}']`);
+ await app.useXpath().click('//android.widget.Spinner[@content-desc="password-input"]');
+ await app.useXpath().click(`//*[@text = '${password}']`);
+ await app.useXpath().click('//android.view.ViewGroup[@content-desc="login-btn"]');
+ }
+}
+
+module.exports = new LoginPage();
diff --git a/tests/pages/page.js b/tests/pages/page.js
new file mode 100644
index 0000000..cd9ac49
--- /dev/null
+++ b/tests/pages/page.js
@@ -0,0 +1,18 @@
+module.exports = class Page {
+
+
+ async swipeOnElement(app) {
+
+ await app.executeScript('mobile:swipeGesture', {
+ 'left':170,
+ 'top':550,
+ 'height':400,
+ 'width':700,
+ 'direction':'left',
+ 'percent':0.75,
+
+ });
+
+ }
+
+};
diff --git a/tests/single/single_ios.js b/tests/single/single_ios.js
new file mode 100644
index 0000000..61daf9b
--- /dev/null
+++ b/tests/single/single_ios.js
@@ -0,0 +1,12 @@
+describe('IOS app test', function () {
+
+ it('Text Verification', async function (app) {
+ app
+ .useXpath().click('//XCUIElementTypeButton[@name="Text Button"]')
+ .useXpath().click("//XCUIElementTypeTextField[@name='Text Input']")
+ .useXpath().sendKeys("//XCUIElementTypeTextField[@name='Text Input']",['Browserstack',browser.Keys.ENTER])
+ .assert.elementPresent({ selector: '//XCUIElementTypeStaticText[@name="Text Output"]', locateStrategy: 'xpath' })
+ .assert.textEquals({ selector: '//XCUIElementTypeStaticText[@name="Text Output"]', locateStrategy: 'xpath'}, 'Browserstack')
+ .pause(2000);
+ });
+ });
diff --git a/tests/specs/cart/cart.spec.js b/tests/specs/cart/cart.spec.js
new file mode 100644
index 0000000..ef0bd8d
--- /dev/null
+++ b/tests/specs/cart/cart.spec.js
@@ -0,0 +1,15 @@
+const HomePage = require("../../pages/home.page");
+const CartPage = require("../../pages/cart.page");
+
+describe('Cart Test', function() {
+
+ it(`User should be able to delete from cart`, async function (app){
+ await HomePage.scrollAndAddToCart(app,"add-to-cart-16");
+ await HomePage.openCart(app);
+ await CartPage.swipeOnElement(app);
+ await app.useXpath().click('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]');
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="number-of-products"]', locateStrategy: 'xpath'}, '0 product(s) found.')
+
+ });
+
+});
diff --git a/tests/specs/e2e/e2e.spec.js b/tests/specs/e2e/e2e.spec.js
new file mode 100644
index 0000000..ef2a7e3
--- /dev/null
+++ b/tests/specs/e2e/e2e.spec.js
@@ -0,0 +1,31 @@
+const LoginPage = require("../../pages/login.page");
+const HomePage = require("../../pages/home.page");
+const CartPage = require("../../pages/cart.page");
+const CheckoutPage = require("../../pages/checkout.page");
+const ConfirmationPage = require("../../pages/confirmation.page");
+
+describe('End to End test', function () {
+
+ it(`User should be able to login and order a product`, async function (app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,"fav_user", "testingisfun99");
+ await HomePage.scrollAndAddToCart(app,"add-to-cart-12");
+ await HomePage.scrollAndAddToCart(app,"add-to-cart-16");
+ await HomePage.scrollAndAddToCart(app,"add-to-cart-11");
+ await HomePage.openCart(app);
+ await CartPage.proceedToCheckout(app);
+ await CheckoutPage.enterShippingDetails(app,
+ "firstname",
+ "lastname",
+ "address",
+ "state",
+ "12345"
+ );
+ await ConfirmationPage.clickContinue(app);
+ await HomePage.openMenu(app);
+ await HomePage.selectMenuOption(app,"Orders");
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="number-of-orders"]', locateStrategy: 'xpath'}, '1 order(s) found.')
+
+ });
+
+});
diff --git a/tests/specs/login/login.spec.js b/tests/specs/login/login.spec.js
new file mode 100644
index 0000000..0f8fc1e
--- /dev/null
+++ b/tests/specs/login/login.spec.js
@@ -0,0 +1,41 @@
+const LoginPage = require("../../pages/login.page");
+const HomePage = require("../../pages/home.page");
+
+describe('BStackDemo login', function () {
+
+
+
+ it(`Login should be successful for account with username 'fav_user'`, async function(app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,"fav_user", "testingisfun99");
+
+ await HomePage.openMenu(app);
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="username"]', locateStrategy: 'xpath'}, 'Welcome fav_user')
+ await HomePage.logout(app);
+ await app.appium.startActivity({
+ appPackage: 'com.browserstack.demo.app',
+ appActivity: 'host.exp.exponent.MainActivity'
+ })
+ });
+
+ it(`Login should not be successful for account with username 'locked_user'`, async function (app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,"locked_user", "testingisfun99");
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="api-error"]', locateStrategy: 'xpath'}, 'Your account has been locked.')
+ await app.appium.startActivity({
+ appPackage: 'com.browserstack.demo.app',
+ appActivity: 'host.exp.exponent.MainActivity'
+ })
+ });
+
+ it(`Login should not be successful for account with incorrect username and password`, async function (app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,"invalid_user", "testingisfun99");
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="api-error"]', locateStrategy: 'xpath'}, 'Invalid Username')
+
+ await LoginPage.login(app,"fav_user", "wrong_password");
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="api-error"]', locateStrategy: 'xpath'}, 'Invalid Password')
+
+ });
+
+});
diff --git a/tests/specs/login/login_data_driven.spec.js b/tests/specs/login/login_data_driven.spec.js
new file mode 100644
index 0000000..567e73b
--- /dev/null
+++ b/tests/specs/login/login_data_driven.spec.js
@@ -0,0 +1,24 @@
+const LoginPage = require("../../pages/login.page");
+const HomePage = require("../../pages/home.page");
+const items = require('../../../resources/data/login_cases.json');
+
+describe('Login validation by dataset', function() {
+
+ it(`Login should not be successful for first invalid account`, async function(app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,items[0].username, items[0].password);
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="api-error"]', locateStrategy: 'xpath'}, items[0].expected_message);
+
+ await app.appium.startActivity({
+ appPackage: 'com.browserstack.demo.app',
+ appActivity: 'host.exp.exponent.MainActivity'
+ })
+ });
+ it(`Login should not be successful for second invalid accounts`, async function(app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,items[1].username, items[1].password);
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="api-error"]', locateStrategy: 'xpath'}, items[1].expected_message);
+ });
+
+
+});
diff --git a/tests/specs/login/login_requested.spec.js b/tests/specs/login/login_requested.spec.js
new file mode 100644
index 0000000..ccf86b6
--- /dev/null
+++ b/tests/specs/login/login_requested.spec.js
@@ -0,0 +1,13 @@
+const LoginPage = require("../../pages/login.page");
+const HomePage = require("../../pages/home.page");
+
+describe('BStackDemo login', function () {
+
+ it(`Favourites navigates to login page`, async function(app) {
+ await HomePage.openMenu(app);
+ await HomePage.selectMenuOption(app,'Favourites');
+ await app.assert.visible({ selector: '//android.view.ViewGroup[@content-desc="login-form"]',locateStrategy: 'xpath'})
+
+ });
+
+});
diff --git a/tests/specs/offers/offers.spec.js b/tests/specs/offers/offers.spec.js
new file mode 100644
index 0000000..a66d4e7
--- /dev/null
+++ b/tests/specs/offers/offers.spec.js
@@ -0,0 +1,37 @@
+const LoginPage = require("../../pages/login.page");
+const HomePage = require("../../pages/home.page");
+const SingaporeLocation = { latitude: "1.0", longitude: "103.0", altitude: "10.0" };
+const AmsterdamLocation = { latitude: "52.36", longitude: "4.9", altitude: "10.0" };
+
+describe('Offers section', function () {
+
+
+ it(`should show offers for 'Singapore'`, async function (app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,"fav_user", "testingisfun99");
+ await app.appium.setGeolocation(SingaporeLocation);
+ await HomePage.openMenu(app);
+ await HomePage.selectMenuOption(app,"Offers");
+ await app.click('id', 'com.android.permissioncontroller:id/permission_allow_foreground_only_button');
+ await app.pause(2000);
+ let offers=await app.useXpath().findElements('//android.view.ViewGroup[@content-desc="offer"]')
+ await app.assert.equal(offers.length,3);
+ await HomePage.openMenu(app);
+ await HomePage.logout(app);
+
+
+
+ });
+
+ it(`should not show offers for 'Amsterdam'`,async function (app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,"fav_user", "testingisfun99");
+ await app.appium.setGeolocation(AmsterdamLocation);
+ await HomePage.openMenu(app);
+ await HomePage.selectMenuOption(app,"Offers");
+ await app.pause(2000);
+ // await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="no-offers"]', locateStrategy: 'xpath'}, 'Sorry we do not have any promotional offers in your city.')
+
+ });
+
+});
diff --git a/tests/specs/user/user.spec.js b/tests/specs/user/user.spec.js
new file mode 100644
index 0000000..a1664dc
--- /dev/null
+++ b/tests/specs/user/user.spec.js
@@ -0,0 +1,38 @@
+const LoginPage = require("../../pages/login.page");
+const HomePage = require("../../pages/home.page");
+
+describe('User', function () {
+
+
+ it(`should see existing orders for 'existing_orders_user'`, async function(app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,
+ "existing_orders_user",
+ "testingisfun99"
+ );
+ await HomePage.openMenu(app);
+ await HomePage.selectMenuOption(app,"Orders");
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="number-of-orders"]', locateStrategy: 'xpath'}, '5 order(s) found.')
+ await HomePage.openMenu(app);
+ await HomePage.logout(app);
+ await app.appium.startActivity({
+ appPackage: 'com.browserstack.demo.app',
+ appActivity: 'host.exp.exponent.MainActivity'
+ })
+ });
+
+ it(`should be able to add to favourites`, async function (app) {
+ await HomePage.openLoginForm(app);
+ await LoginPage.login(app,
+ "existing_orders_user",
+ "testingisfun99"
+ );
+ await HomePage.markProductFavourite(app,"mark-favourite-12");
+ await HomePage.markProductFavourite(app,"mark-favourite-16");
+ await HomePage.openMenu(app);
+ await HomePage.selectMenuOption(app,"Favourites");
+ await app.assert.textEquals({ selector: '//android.widget.TextView[@content-desc="number-of-favourites"]', locateStrategy: 'xpath'}, '2 product(s) marked favourite.')
+
+ });
+
+});