-
Notifications
You must be signed in to change notification settings - Fork 39
Updated directory structure, readme, and added parallel testing sample code #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kn-neeraj
wants to merge
34
commits into
browserstack:master
Choose a base branch
from
kn-neeraj:python3-readme-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
43e97a1
Updated main Readme.md file
kn-neeraj baae2c7
Updated main readme.md documentation
kn-neeraj abf0536
Fixed typo errors in main Readme file
kn-neeraj a1c6928
Updated Readme.md documentation text and fixed few typos
kn-neeraj b175723
Updated link to download pip and fixed typos.
kn-neeraj 5e47602
Updated main README.md and deleted android, ios specific readme
kn-neeraj 3d6d245
Adding links to Getting Help section if user faces any issues.
kn-neeraj 151cbdc
Updated file structure, added support for parallel testing
kn-neeraj d362136
Deleting old test files, Added .gitignore
kn-neeraj a1e3103
Removing local.log file from examples/ios/run_local_test directory
kn-neeraj 3b26b5e
Removing sample app BrowserStack URLs from json files.
kn-neeraj 0d4dd0b
Updated Github Readme
kn-neeraj 61b0818
Updated directory names under examples, updated readme.md, support fo…
kn-neeraj f068615
Updating name of first test as "first_test" in config files
kn-neeraj c9bb28f
Updated Readme to decouple instructions for installation of dependenc…
kn-neeraj 0a70948
Small typo fix in Github readme
kn-neeraj 27fa7ed
Solving threading issue while running parallel tests and updated comm…
kn-neeraj a4899f6
Update Github readme content and links to new documentation
kn-neeraj c570250
Updating readme with minimum Python supported version as Python 3.6
kn-neeraj 5109ccd
Added note about pip coming pre-installed in some Python versions in …
kn-neeraj 8ed2769
Adding app URL placeholder test in config files
kn-neeraj c85e0c4
Adding placeholders for App URL in Android parallel testing config file
kn-neeraj e8733a2
Updated developer documentation URL in Readme
kn-neeraj ee92806
Decoupling python3 and python2 installation commands
kn-neeraj 8a2ea09
Updated print statement
kn-neeraj 3a769f3
Updated print statement
kn-neeraj f8b7ae6
Updated print statement
kn-neeraj f3993bd
Updated print statement
kn-neeraj 241d174
Updated print statement
kn-neeraj 50c85bc
Adding new line to search input
kn-neeraj 5e7dfba
Adding new line to search input
kn-neeraj 0e6ba9b
Resolving PR comments
kn-neeraj 9fbb620
Merge branch 'python3-readme-changes' of https://github.com/kn-neeraj…
kn-neeraj 062861b
Added specific versions for dependencies, updated config files
kn-neeraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| */local.log | ||
| */browserstack.err | ||
| */**.pyc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,108 @@ | ||
| # python-appium-app-browserstack | ||
| App Automate Python Samples | ||
| --------------------- | ||
|
|
||
| This repository contains code for Automated Native App tests. Please feel free to clone the repo and use the example code. | ||
| Refer [Getting Started with App Automate](https://www.browserstack.com/app-automate/appium-python) for more details. | ||
| This repository demonstrates how to run Appium tests using Python on BrowserStack App Automate. | ||
|
|
||
| ## Setup | ||
|
|
||
| ### Requirements | ||
|
|
||
| 1. Python 3.6+ or Python 2.7+ | ||
|
|
||
| - If Python is not installed, follow these instructions: | ||
| - For Windows, download latest python version from [here](https://www.python.org/downloads/windows/) and run the installer executable | ||
| - For Mac and Linux, run `python --version` to see what python version is pre-installed. If you want a different version download from [here](https://www.python.org/downloads/) | ||
|
|
||
| 2. Package Manager `pip` | ||
|
|
||
| Note : `pip` comes installed with Python 2.7.9+ and python 3.4+ | ||
|
|
||
| - If `pip` is not installed, follow these instructions: | ||
| - Securely download get-pip.py by following this link: [get-pip.py](https://bootstrap.pypa.io/get-pip.py) or use following cURL command to download it: | ||
|
|
||
| ```sh | ||
| curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | ||
| ``` | ||
|
|
||
| - After dowloading, run the file : | ||
|
|
||
| - For Python 3 | ||
|
|
||
| ```sh | ||
| python3 get-pip.py | ||
| ``` | ||
|
|
||
| - For Python 2 | ||
|
|
||
| ```sh | ||
| python2 get-pip.py | ||
| ``` | ||
|
|
||
| ### Install the dependencies | ||
|
|
||
| To install the dependencies for Android tests, run : | ||
|
|
||
| - For Python 3 | ||
|
|
||
| ```sh | ||
| pip3 install -r android/requirements.txt | ||
| ``` | ||
|
|
||
| - For Python 2 | ||
|
|
||
| ```sh | ||
| pip2 install -r android/requirements.txt | ||
| ``` | ||
|
|
||
| Or, | ||
|
|
||
| To install the dependencies for iOS tests, run : | ||
|
|
||
| - For Python 3 | ||
|
|
||
| ```sh | ||
| pip3 install -r ios/requirements.txt | ||
| ``` | ||
|
|
||
| - For Python 2 | ||
|
|
||
| ```sh | ||
| pip2 install -r ios/requirements.txt | ||
| ``` | ||
|
|
||
|
|
||
| ## Getting Started | ||
|
|
||
| Getting Started with Appium tests in Python on real BrowserStack devices couldn't be easier! | ||
|
|
||
| ### **Run first test :** | ||
|
|
||
| - Switch to `run-first-test` directory under [Android examples](android/examples/run-first-test) or [iOS examples](ios/examples/run-first-test) | ||
|
|
||
| - Follow the steps outlined in the documentation [Getting Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/python) | ||
|
|
||
| ### **Speed up test execution with parallel testing :** | ||
|
|
||
| - Switch to `run-prarallel-tests` directory under [Android examples](android/examples/run-parallel-tests) or [iOS examples](ios/examples/run-parallel-tests) | ||
|
|
||
| - Follow the steps outlined in the documentation [Getting Started with Parallel testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/python/parallelize-tests) | ||
|
|
||
| ### **Use Local testing for apps that access resources hosted in development or testing environments :** | ||
|
|
||
| - Switch to `run-local-test` directory under [Android examples](android/examples/run-local-test) or [iOS examples](ios/examples/run-local-test) | ||
|
|
||
| - Follow the steps outlined in the documentation [Getting Started with Local testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/python/local-testing) | ||
|
|
||
| **Note**: If you face any issues, refer [Getting Help section](#Getting-Help) | ||
|
|
||
| ## Integration with other python frameworks | ||
|
|
||
| For other Python frameworks samples, refer to following repositories : | ||
|
|
||
| For frameworks integration with BrowserStack, refer to their individual repositories - | ||
| - [Lettuce](https://github.com/browserstack/lettuce-appium-app-browserstack) | ||
| - [Behave](https://github.com/browserstack/behave-appium-app-browserstack) | ||
| - [Lettuce](https://github.com/browserstack/lettuce-appium-app-browserstack) | ||
|
|
||
| Note: For other test frameworks supported by App-Automate refer our [Developer documentation](https://www.browserstack.com/docs/) | ||
|
|
||
| ## Getting Help | ||
|
|
||
| For python 2 support refer the branch | ||
| - [python-2-master](https://github.com/browserstack/python-appium-app-browserstack/tree/python-2-master) | ||
| If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help). |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "username":"BROWSERSTACK_USERNAME", | ||
| "access_key":"BROWSERSTACK_ACCESS_KEY", | ||
|
|
||
| "capabilities": { | ||
| "project": "First Python Android Project", | ||
| "build": "Python Android", | ||
| "name": "first_test", | ||
| "browserstack.debug": true, | ||
| "app": "bs://<hashed app-id>", | ||
| "device": "Google Pixel" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| from appium import webdriver | ||
| from appium.webdriver.common.mobileby import MobileBy | ||
| from selenium.webdriver.support.ui import WebDriverWait | ||
| from selenium.webdriver.support import expected_conditions as EC | ||
| import time | ||
| import os, json | ||
|
|
||
| config_file_path = os.path.join(os.path.dirname(__file__), "config.json") | ||
| print("Config file path = %s" % (config_file_path)) | ||
| with open(config_file_path) as config_file: | ||
| CONFIG = json.load(config_file) | ||
|
|
||
| BROWSERSTACK_USERNAME = os.environ['BROWSERSTACK_USERNAME'] if 'BROWSERSTACK_USERNAME' in os.environ else CONFIG['username'] | ||
| BROWSERSTACK_ACCESS_KEY = os.environ['BROWSERSTACK_ACCESS_KEY'] if 'BROWSERSTACK_ACCESS_KEY' in os.environ else CONFIG['access_key'] | ||
|
|
||
| def test(): | ||
| """ | ||
| Test for BrowserStack sample Wikipedia Android app. | ||
| Note: If you have uploaded your app to BrowserStack update the test here. | ||
| """ | ||
|
|
||
| desired_capabilities = CONFIG['capabilities'] | ||
|
|
||
| driver = webdriver.Remote( | ||
| desired_capabilities = desired_capabilities, | ||
| command_executor = "http://%s:%s@hub-cloud.browserstack.com/wd/hub" % (BROWSERSTACK_USERNAME, BROWSERSTACK_ACCESS_KEY) | ||
| ) | ||
|
|
||
| search_element = WebDriverWait(driver, 30).until ( | ||
| EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID, "Search Wikipedia")) | ||
| ) | ||
|
|
||
| search_element.click() | ||
|
|
||
| search_input = WebDriverWait(driver, 30).until ( | ||
| EC.element_to_be_clickable((MobileBy.ID, "org.wikipedia.alpha:id/search_src_text")) | ||
| ) | ||
|
|
||
| search_input.send_keys("BrowserStack") | ||
|
kn-neeraj marked this conversation as resolved.
Outdated
|
||
|
|
||
| time.sleep(5) | ||
|
|
||
| search_results = driver.find_elements_by_class_name("android.widget.TextView") | ||
|
|
||
| assert(len(search_results) > 0) | ||
|
|
||
| driver.quit() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test() | ||
|
kn-neeraj marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "username":"BROWSERSTACK_USERNAME", | ||
| "access_key":"BROWSERSTACK_ACCESS_KEY", | ||
|
|
||
| "capabilities": { | ||
| "project": "First Python Android Project", | ||
| "build": "Python Android Local", | ||
| "name": "local_test", | ||
| "browserstack.debug": true, | ||
| "app": "bs://<hashed app-id>", | ||
| "device": "Samsung Galaxy S7", | ||
| "browserstack.local": true | ||
| } | ||
|
kn-neeraj marked this conversation as resolved.
|
||
| } | ||
|
kn-neeraj marked this conversation as resolved.
Outdated
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.