├── .gitignore ├── LICENSE ├── README.md ├── package_tests.sh ├── start-appium-ios.sh └── tests ├── __init__.py ├── pages ├── __init__.py ├── alerts_page.py ├── base_pages │ ├── __init__.py │ ├── base_page.py │ └── tab_view_page.py ├── inputs │ ├── __init__.py │ └── date_selector_page.py ├── login_page.py ├── native │ ├── __init__.py │ ├── image_gallery_page.py │ └── video_player_page.py ├── navigation_page.py ├── nested_views_page.py └── web_page.py └── tests ├── __init__.py ├── alerts_test.py ├── base_tests ├── __init__.py ├── base_tab_test.py └── base_test.py ├── inputs ├── __init__.py └── date_selector_test.py ├── login_test.py ├── native ├── __init__.py ├── image_gallery_test.py └── video_player_test.py ├── nested_views_test.py └── web_test.py /.gitignore: -------------------------------------------------------------------------------- 1 | .Python 2 | bin/ 3 | include/ 4 | lib/ 5 | pip-selfcheck.json 6 | requirements.txt 7 | selenium/ 8 | wheelhouse/ 9 | *.pyc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Appium Python Sample Tests for AWS Device Farm Sample iOS App 2 | This is a collection of sample Appium Python tests written for the AWS Device Farm [iOS sample app](https://github.com/awslabs/aws-device-farm-sample-app-for-ios). This test suite uses the [Appium page model](http://appium.io/slate/en/tutorial/android?java#page-object-pattern) to separate the tests from the page logic. You may use these tests as a starting reference for writing your own AWS Device Farm Appium Python Tests. 3 | Note: Your tests may be different than these and it is not a hard requirement that they exactly follow this model. This is an example for lookup. 4 | 5 | ## Getting Started - Installing Appium 6 | ### Using the Appium GUI 7 | 1. Download and install the Appium GUI. [[Windows Download]](https://bitbucket.org/appium/appium.app/downloads/AppiumForWindows_1_4_16_1.zip). [[OS X Download]](https://bitbucket.org/appium/appium.app/downloads/appium-1.4.13.dmg). 8 | 9 | **AWS Device Farm currently supports Appium version 1.4.16. Using a different version locally may cause unexpected results when running Appium tests on AWS Device Farm. It would be always helpful to check the AWS Forums for checking the latest supported version.** 10 | 11 | 2. Read the Appium GUI [documentation](http://appium.io/slate/en/v1.4.13/#appium-gui). 12 | 13 | ### Using the Appium CLI 14 | 1. Follow the **[official Appium getting started guide](http://appium.io/slate/en/tutorial/android.html?java#getting-started-with-appium)** and install the Appium server and dependencies. 15 | 16 | **AWS Device Farm currently supports Appium version 1.4.16. Using a different version locally may cause unexpected results when running Appium tests on AWS Device Farm. It would be always helpful to check the AWS Forums for checking the latest supported version.** 17 | 2. In order to use 1.4.16, download Appium through NPM with this command: 18 | 19 | ``` 20 | $ npm install -g appium@1.4.16 21 | ``` 22 | 23 | 3. Verify that you have Appium installed with this command: 24 | 25 | ``` 26 | $ appium -v 27 | ``` 28 | 29 | You should get "1.4.16" as the output 30 | 31 | ## Set up the Appium Python environment 32 | 1. We recommend setting up [Python's virtualenv](https://pypi.python.org/pypi/virtualenv) for developing and packaging tests so that unnecessary dependencies are not including in the bundled zip file. 33 | 2. Create your workspace and install py.test in your virtual environment. For example: 34 | 35 | ``` 36 | $ virtualenv workspace 37 | $ cd workspace 38 | $ source bin/activate 39 | $ pip install pytest 40 | $ pip install Appium-Python-Client 41 | ``` 42 | 43 | 3. Put all Python test scripts under a **tests/** folder in your workspace. 44 | 45 | ``` 46 | - workspace 47 | └─ tests/ (tests go here) 48 | ``` 49 | 50 | ## Running Your Tests Locally on Real Devices 51 | 52 | ### **Important Note** 53 | Certain desired capabilities must be set when running locally. Refer to [BaseTest.java](./tests/tests/base_tests/base_test.py#L26-L32) 54 | 55 | ### Appium GUI 56 | 1. Start the Appium server. 57 | 1. Click on the iOS button. 58 | 2. Set the "App Path" and "UDID" and make sure their checkboxes are checked. 59 | 3. Press the "Launch" button to start the Appium server locally. 60 | 2. Navigate into your workspace project directory in the terminal and activate the virtualenv. 61 | 62 | ``` 63 | $ source bin/activate 64 | ``` 65 | 66 | 3. Verify that your test cases are discoverable by the following command, which should be run from your workspace folder. 67 | 68 | ``` 69 | $ py.test --collect-only tests/ 70 | ``` 71 | 72 | 4. Run your tests. 73 | 74 | ``` 75 | $ py.test tests/ 76 | ``` 77 | 78 | ### Appium CLI 79 | 1. Start the Appium server. 80 | 1. Make sure that you have followed all the steps in the [Appium getting started guide](http://appium.io/slate/en/tutorial/ios.html?java#getting-started-with-appium). 81 | 2. Edit the [start-appium-ios.sh](./start-appium-ios.sh) script to include your app's absolute path and your device's UDID. 82 | 3. Run [start-appium-ios.sh](./start-appium-ios.sh) to start the Appium server locally. 83 | 2. Navigate into your workspace project directory in the terminal and activate the virtualenv. 84 | 85 | ``` 86 | $ source bin/activate 87 | ``` 88 | 89 | 3. Verify that your test cases are discoverable by the following command, which should be run from your workspace folder. 90 | 91 | ``` 92 | $ py.test --collect-only tests/ 93 | ``` 94 | 4. Run your tests. 95 | 96 | ``` 97 | $ py.test tests/ 98 | ``` 99 | 100 | 101 | ### Running tests on AWS Device Farm 102 | #### Step 1: Navigate into your workspace project directory and activate the virtualenv. 103 | 104 | ``` 105 | $ source bin/activate 106 | ``` 107 | 108 | #### Step 2: Package your tests. 109 | 110 | ``` 111 | $ ./package_tests.sh 112 | ``` 113 | 114 | #### Step 3: Upload to AWS Device Farm. 115 | Follow these [instructions](http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-ios-appium-python.html#test-types-ios-appium-python-upload) and upload **test_bundle.zip** on Step 9. 116 | 117 | -------------------------------------------------------------------------------- /package_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | py.test --collect-only tests/ 4 | 5 | read -rsp $'\nMake sure desired capabilities is empty.\n\tVerify your tests were collected, press any key to continue or CTRL+C to abort.\n' -n1 key 6 | 7 | ## Remove cached files 8 | find . -name '__pycache__' -type d -exec rm -r {} + 9 | find . -name '*.pyc' -exec rm -f {} + 10 | find . -name '*.pyo' -exec rm -f {} + 11 | find . -name '*~' -exec rm -f {} + 12 | 13 | ## Write installed packages to requirements.txt 14 | pip freeze > requirements.txt 15 | 16 | ## Build wheel archive 17 | pip wheel --wheel-dir wheelhouse -r requirements.txt 18 | 19 | ## Zip tests/, wheelhouse/, and requirements.txt into test_bundle.zip 20 | zip -r test_bundle.zip tests/ wheelhouse/ requirements.txt 21 | -------------------------------------------------------------------------------- /start-appium-ios.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Assumes the .ipa file is in the same directory as this script. 4 | 5 | directory_path="$(pwd *.ipa)" 6 | file_name="$(basename *.ipa)" 7 | app_absolute_path="${directory_path}/${file_name}" 8 | 9 | appium --platform-name ios --app $app_absolute_path --udid -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | from pages import * 2 | -------------------------------------------------------------------------------- /tests/pages/__init__.py: -------------------------------------------------------------------------------- 1 | from alerts_page import AlertsPage 2 | from login_page import LoginPage 3 | from navigation_page import NavigationPage 4 | from nested_views_page import NestedViewsPage 5 | from web_page import WebPage 6 | from tests.pages.base_pages.tab_view_page import TabViewPage 7 | from tests.pages.base_pages.base_page import BasePage 8 | from tests.pages.inputs.date_selector_page import DateSelectorPage 9 | from tests.pages.native.video_player_page import VideoPlayerPage 10 | from tests.pages.native.image_gallery_page import ImageGalleryPage 11 | -------------------------------------------------------------------------------- /tests/pages/alerts_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import BasePage 15 | 16 | 17 | class AlertsPage(BasePage): 18 | """Alerts page representation.""" 19 | OK_BUTTON_ID = 'OK' 20 | MODAL_BUTTON_ID = 'Modal' 21 | 22 | def click_modal_button(self): 23 | """Taps the modal button.""" 24 | modal_button = self.driver.find_element_by_accessibility_id(self.MODAL_BUTTON_ID) 25 | modal_button.click() 26 | 27 | def modal_text_is_displayed(self): 28 | """Returns visibility of modal's message as a boolean.""" 29 | modal_text = self.driver.find_element_by_class_name(self.STATIC_TEXT_CLASS) 30 | return modal_text.is_displayed() 31 | 32 | def accept_message(self): 33 | """Taps the OK button to accept the modal.""" 34 | ok_button = self.driver.find_element_by_accessibility_id(self.OK_BUTTON_ID) 35 | ok_button.click() 36 | -------------------------------------------------------------------------------- /tests/pages/base_pages/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-device-farm-appium-python-tests-for-ios-sample-app/f30cba8605eada6b947c931261b537e2479aa53b/tests/pages/base_pages/__init__.py -------------------------------------------------------------------------------- /tests/pages/base_pages/base_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | 15 | class BasePage: 16 | """ The basis for all pages. 17 | 18 | Contains UIA class names and defines implicit wait and timeouts. 19 | """ 20 | STATIC_TEXT_CLASS = 'UIAStaticText' 21 | PICKER_WHEEL_CLASS = 'UIAPickerWheel' 22 | COLLECTION_VIEW_CLASS = 'UIACollectionView' 23 | TEXT_FIELD_CLASS = 'UIATextField' 24 | SECURE_TEXT_FIELD_CLASS = 'UIASecureTextField' 25 | WEB_VIEW_CLASS = 'UIAWebView' 26 | 27 | IMPLICIT_WAIT_TIME = 10 28 | TIMEOUT = 30 29 | 30 | def __init__(self, driver): 31 | """Base constructor. 32 | 33 | Sets driver, implicit wait, and timeout. 34 | """ 35 | self.driver = driver 36 | self.driver.implicitly_wait(self.IMPLICIT_WAIT_TIME) 37 | self.timeout = self.TIMEOUT 38 | -------------------------------------------------------------------------------- /tests/pages/base_pages/tab_view_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from base_page import BasePage 15 | 16 | 17 | class TabViewPage(BasePage): 18 | """Base for a tab view page.""" 19 | START_OFFSET = 0.95 20 | END_OFFSET = 0.05 21 | SWIPE_DURATION = 1000 22 | 23 | def go_to_next_page(self): 24 | """Swipes left to go to next page in tab view drawer.""" 25 | size = self.driver.get_window_size() 26 | start_x = size['width'] * self.START_OFFSET 27 | end_x = size['width'] * self.END_OFFSET 28 | start_y = size['height'] / 2 29 | 30 | self.driver.swipe(start_x, start_y, end_x, start_y, self.SWIPE_DURATION) 31 | -------------------------------------------------------------------------------- /tests/pages/inputs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-device-farm-appium-python-tests-for-ios-sample-app/f30cba8605eada6b947c931261b537e2479aa53b/tests/pages/inputs/__init__.py -------------------------------------------------------------------------------- /tests/pages/inputs/date_selector_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import BasePage 15 | 16 | 17 | class DateSelectorPage(BasePage): 18 | MONTH_INDEX = 0 19 | DAY_INDEX = 1 20 | YEAR_INDEX = 2 21 | 22 | """Date selector page representation.""" 23 | def set_date(self, month, day, year): 24 | """Sets month, day, year, picker wheels. 25 | 26 | month -- the month as a string 27 | day -- the day as a string 28 | year -- the year as a string 29 | """ 30 | wheels = self.driver.find_elements_by_class_name(self.PICKER_WHEEL_CLASS) 31 | 32 | month_wheel = wheels[MONTH_INDEX] 33 | day_wheel = wheels[DAY_INDEX] 34 | year_wheel = wheels[YEAR_INDEX] 35 | 36 | month_wheel.send_keys(month) 37 | day_wheel.send_keys(day) 38 | year_wheel.send_keys(year) 39 | 40 | def get_selected_date(self): 41 | """Retrieves selected date as a string (Month is truncated to three letters).""" 42 | date = self.driver.find_element_by_class_name(self.STATIC_TEXT_CLASS) 43 | return date.text 44 | -------------------------------------------------------------------------------- /tests/pages/login_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import BasePage 15 | 16 | 17 | class LoginPage(BasePage): 18 | """Login page representation.""" 19 | LOGIN_BUTTON_ID = 'Login' 20 | LOGGED_IN_MESSAGE_ID = 'Logged in as admin' 21 | PERMISSION_DENIED_MESSAGE_ID = 'PERMISSION DENIED' 22 | LOGOUT_BUTTON_ID = 'log out' 23 | TRY_AGAIN_BUTTON_ID = 'try again' 24 | 25 | def get_element_center(self, element): 26 | """Calculates the center of inputted element and returns it as a tuple (x, y).""" 27 | element_mid_width = element.size['width'] / 2 28 | element_mid_height = element.size['height'] / 2 29 | return element.location['x'] + element_mid_width, element.location['y'] + element_mid_height 30 | 31 | def tap_button_center(self, element): 32 | """Taps the center of an element. 33 | 34 | This was needed because "clickable" was disabled for some elements. 35 | """ 36 | button_center = self.get_element_center(element) 37 | self.driver.tap([button_center], 1) 38 | 39 | def log_in(self, username, password): 40 | """Types in inputted username and password and presses log in button.""" 41 | username_field = self.driver.find_element_by_class_name(self.TEXT_FIELD_CLASS) 42 | password_field = self.driver.find_element_by_class_name(self.SECURE_TEXT_FIELD_CLASS) 43 | log_in_button = self.driver.find_element_by_accessibility_id(self.LOGIN_BUTTON_ID) 44 | 45 | username_field.send_keys(username) 46 | password_field.send_keys(password) 47 | log_in_button.click() 48 | 49 | def is_valid_login_message_displayed(self): 50 | """Returns visibility of valid login message as a boolean.""" 51 | logged_in_message = self.driver.find_element_by_accessibility_id(self.LOGGED_IN_MESSAGE_ID) 52 | return logged_in_message.is_displayed() 53 | 54 | def is_invalid_login_message_displayed(self): 55 | """Returns visibility of invalid login message as a boolean.""" 56 | permission_denied_message = self.driver.find_element_by_accessibility_id(self.PERMISSION_DENIED_MESSAGE_ID) 57 | return permission_denied_message.is_displayed() 58 | 59 | def click_log_out_button(self): 60 | """Taps the log out button.""" 61 | log_out_button = self.driver.find_element_by_accessibility_id(self.LOGOUT_BUTTON_ID) 62 | self.tap_button_center(log_out_button) 63 | 64 | def click_try_again_button(self): 65 | """Taps the try again button.""" 66 | try_again_button = self.driver.find_element_by_accessibility_id(self.TRY_AGAIN_BUTTON_ID) 67 | self.tap_button_center(try_again_button) 68 | 69 | def is_at_login(self): 70 | """Returns whether or not we are back at the original login view as a boolean. 71 | 72 | Simply checks the visibility of the login button. 73 | """ 74 | log_in_button = self.driver.find_element_by_accessibility_id(self.LOGIN_BUTTON_ID) 75 | return log_in_button.is_displayed() 76 | -------------------------------------------------------------------------------- /tests/pages/native/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-device-farm-appium-python-tests-for-ios-sample-app/f30cba8605eada6b947c931261b537e2479aa53b/tests/pages/native/__init__.py -------------------------------------------------------------------------------- /tests/pages/native/image_gallery_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import * 15 | 16 | 17 | class ImageGalleryPage(BasePage): 18 | """Image gallery page representation.""" 19 | def image_gallery_is_displayed(self): 20 | """Returns visibility of image gallery as a boolean.""" 21 | image_gallery = self.driver.find_element_by_class_name(self.COLLECTION_VIEW_CLASS) 22 | return image_gallery.is_displayed() 23 | -------------------------------------------------------------------------------- /tests/pages/native/video_player_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import BasePage 15 | from selenium.webdriver.support import expected_conditions as ec 16 | from selenium.webdriver.support.ui import WebDriverWait 17 | from selenium.webdriver.common.by import By 18 | 19 | 20 | class VideoPlayerPage(BasePage): 21 | """Video player page representation.""" 22 | SIMULATOR_VIDEO_LOAD_TIME = 30 23 | MEDIA_PLAYER_VIEW_ID = 'MediaPlayerView' 24 | 25 | def video_is_displayed(self): 26 | """Returns visibility of video as a boolean. 27 | 28 | Implicit wait for iOS simulator because it may take some time to load the video. 29 | """ 30 | wait = WebDriverWait(self.driver, self.SIMULATOR_VIDEO_LOAD_TIME) 31 | video_player = wait.until(ec.presence_of_element_located((By.ID, self.MEDIA_PLAYER_VIEW_ID))) 32 | return video_player.is_displayed() 33 | -------------------------------------------------------------------------------- /tests/pages/navigation_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import BasePage 15 | 16 | 17 | class NavigationPage(BasePage): 18 | """Class that handles navigation to different pages within the application.""" 19 | INPUT_ID = 'Inputs' 20 | MORE_ID = 'More' 21 | NATIVE_ID = 'Native' 22 | NATIVE_CATEGORIES = frozenset(['Image Gallery', 'Scrolling View', 'Table of elements', 'Video Player', 23 | 'Camera', 'Out of View Component']) 24 | INPUT_CATEGORIES = frozenset(['Text View', 'Toggle', 'Date Selector', 'Label View', 'Refresh Control', 25 | 'Slider', 'Text Field', 'Submit', 'Selection Wheel', 'Gestures']) 26 | MORE_CATEGORIES = frozenset(['Nested', 'Crash', 'Alerts', 'Web', 'Login']) 27 | 28 | def go_to_category(self, category_name): 29 | """Clicks appropriate navigation bar button depending on the category to which the input belongs. 30 | 31 | i.e. Log in page will fall under More tab, image gallery under native, etc. 32 | 33 | Note: Layouts will be different in different sized devices. The MORE_CATEGORIES is constructed to include all 34 | possible tabs in the More section. On larger devices, the More button may be clicked unnecessarily before 35 | clicking the respective button in the navigation bar. 36 | """ 37 | if category_name in self.INPUT_CATEGORIES: 38 | input_button = self.driver.find_element_by_accessibility_id(self.INPUT_ID) 39 | input_button.click() 40 | 41 | else: 42 | if category_name in self.MORE_CATEGORIES: 43 | more_button = self.driver.find_element_by_accessibility_id(self.MORE_ID) 44 | more_button.click() 45 | elif category_name in self.NATIVE_CATEGORIES: 46 | native_button = self.driver.find_element_by_accessibility_id(self.NATIVE_ID) 47 | native_button.click() 48 | 49 | category_button = self.driver.find_element_by_accessibility_id(category_name) 50 | category_button.click() 51 | -------------------------------------------------------------------------------- /tests/pages/nested_views_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import BasePage 15 | 16 | 17 | class NestedViewsPage(BasePage): 18 | """Nested views page representation.""" 19 | NEXT_BUTTON_ID = 'Next' 20 | BACK_BUTTON_ID = 'Back' 21 | 22 | def click_next_button(self): 23 | """Taps on the next button.""" 24 | next_button = self.driver.find_element_by_accessibility_id(self.NEXT_BUTTON_ID) 25 | next_button.click() 26 | 27 | def click_back_button(self): 28 | """Taps on the back button.""" 29 | back_button = self.driver.find_element_by_accessibility_id(self.BACK_BUTTON_ID) 30 | back_button.click() 31 | 32 | def get_static_text(self): 33 | """Returns text on a nested view page.""" 34 | static_texts = self.driver.find_elements_by_class_name(self.STATIC_TEXT_CLASS) 35 | nested_text = static_texts[-1] # Retrieves the topmost static text object 36 | return nested_text.text 37 | -------------------------------------------------------------------------------- /tests/pages/web_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.pages.base_pages.base_page import BasePage 15 | from selenium.webdriver.support import expected_conditions as ec 16 | from selenium.webdriver.support.ui import WebDriverWait 17 | from selenium.webdriver.common.by import By 18 | 19 | 20 | class WebPage(BasePage): 21 | """Static web page representation.""" 22 | WEBSITE_LOAD_TIME = 10 23 | 24 | def web_view_is_displayed(self): 25 | """Returns visibility of the web view. 26 | 27 | Does not actually check for web page content - look up hybrid page for this. 28 | """ 29 | wait = WebDriverWait(self.driver, self.WEBSITE_LOAD_TIME) 30 | web_view = wait.until(ec.presence_of_element_located((By.CLASS_NAME, self.WEB_VIEW_CLASS))) 31 | return web_view.is_displayed() 32 | -------------------------------------------------------------------------------- /tests/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-device-farm-appium-python-tests-for-ios-sample-app/f30cba8605eada6b947c931261b537e2479aa53b/tests/tests/__init__.py -------------------------------------------------------------------------------- /tests/tests/alerts_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from base_tests.base_test import BaseTest 15 | from tests.pages import AlertsPage 16 | 17 | 18 | class AlertsTest(BaseTest): 19 | """Container for all alerts page tests.""" 20 | def setUp(self): 21 | """Sets up Appium connection and navigates to alerts page.""" 22 | BaseTest.setUp(self) 23 | BaseTest.navigate_to_page(self) 24 | self.alerts_page = AlertsPage(self.driver) 25 | 26 | def get_name(self): 27 | return 'Alerts' 28 | 29 | def test_modal(self): 30 | """Click modal button, verify modal message is displayed, accept the message.""" 31 | self.alerts_page.click_modal_button() 32 | self.assertTrue(self.alerts_page.modal_text_is_displayed()) 33 | self.alerts_page.accept_message() 34 | -------------------------------------------------------------------------------- /tests/tests/base_tests/__init__.py: -------------------------------------------------------------------------------- 1 | from base_test import BaseTest 2 | from base_tab_test import BaseTabTest 3 | -------------------------------------------------------------------------------- /tests/tests/base_tests/base_tab_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from time import sleep 15 | from base_test import BaseTest 16 | from tests.pages import TabViewPage 17 | 18 | 19 | class BaseTabTest(BaseTest): 20 | """Basis for any test for a page that must be swiped to.""" 21 | ANIMATION_DELAY = 1 22 | 23 | def get_name(self): 24 | """Returns name of view.""" 25 | raise NotImplementedError 26 | 27 | def get_page_index(self): 28 | """Returns index of page within the drawer.""" 29 | raise NotImplementedError 30 | 31 | def navigate_to_page(self): 32 | """Navigate to the drawer swipe until it gets to desired page.""" 33 | BaseTest.navigate_to_page(self) 34 | tab_view = TabViewPage(self.driver) 35 | 36 | for __ in range(self.get_page_index()): 37 | tab_view.go_to_next_page() 38 | sleep(self.ANIMATION_DELAY) 39 | -------------------------------------------------------------------------------- /tests/tests/base_tests/base_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | import unittest 15 | from appium import webdriver 16 | from tests.pages import NavigationPage 17 | 18 | 19 | class BaseTest(unittest.TestCase): 20 | """Basis for all tests.""" 21 | def setUp(self): 22 | """Sets up desired capabilities and the Appium driver.""" 23 | url = 'http://127.0.0.1:4723/wd/hub' 24 | desired_caps = {} 25 | 26 | """ 27 | The following desired capabilities must be set when running locally. 28 | Make sure they are NOT set when uploading to Device Farm. 29 | 30 | desired_caps['platformName'] = 'iOS' 31 | desired_caps['deviceName'] = 'iPhone' 32 | """ 33 | 34 | self.driver = webdriver.Remote(url, desired_caps) 35 | self.navigation_page = NavigationPage(self.driver) 36 | 37 | def tearDown(self): 38 | """Shuts down the driver.""" 39 | self.driver.quit() 40 | 41 | def get_name(self): 42 | raise NotImplementedError 43 | 44 | def navigate_to_page(self): 45 | """Navigates to desired page.""" 46 | self.navigation_page.go_to_category(self.get_name()) 47 | -------------------------------------------------------------------------------- /tests/tests/inputs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-device-farm-appium-python-tests-for-ios-sample-app/f30cba8605eada6b947c931261b537e2479aa53b/tests/tests/inputs/__init__.py -------------------------------------------------------------------------------- /tests/tests/inputs/date_selector_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.tests.base_tests import BaseTabTest 15 | from tests.pages import DateSelectorPage 16 | 17 | 18 | class DateSelectorTest(BaseTabTest): 19 | """Container for all date selector page tests.""" 20 | MONTH = 'July' 21 | DAY = '5' 22 | YEAR = '1994' 23 | EXPECTED_DATE = 'Jul 5, 1994' 24 | 25 | def setUp(self): 26 | """Set up Appium connection and navigate to date selector page.""" 27 | BaseTabTest.setUp(self) 28 | BaseTabTest.navigate_to_page(self) 29 | self.date_selector_page = DateSelectorPage(self.driver) 30 | 31 | def get_name(self): 32 | return 'Date Selector' 33 | 34 | def get_page_index(self): 35 | return 2 36 | 37 | def test_date_selector(self): 38 | """Sets date, verifies selected date text.""" 39 | self.date_selector_page.set_date(self.MONTH, self.DAY, self.YEAR) 40 | self.assertEquals(self.date_selector_page.get_selected_date(), self.EXPECTED_DATE) 41 | -------------------------------------------------------------------------------- /tests/tests/login_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from base_tests.base_test import BaseTest 15 | from tests.pages import LoginPage 16 | 17 | 18 | class LoginTest(BaseTest): 19 | """Container for all login page tests.""" 20 | LOGIN_SUCCESS_MESSAGE = 'You are logged on as admin' 21 | LOGIN_FAILURE_MESSAGE = 'You gave me the wrong username and password' 22 | USERNAME = 'admin' 23 | VALID_PASSWORD = 'password' 24 | INVALID_PASSWORD = 'passwrod' 25 | 26 | def setUp(self): 27 | """Sets up Appium connection and navigates to login page.""" 28 | BaseTest.setUp(self) 29 | BaseTest.navigate_to_page(self) 30 | self.login_page = LoginPage(self.driver) 31 | 32 | def get_name(self): 33 | return 'Login' 34 | 35 | def test_valid_login(self): 36 | """Login with valid credentials, verify valid login message, log out, verify back at log in.""" 37 | self.login_page.log_in(self.USERNAME, self.VALID_PASSWORD) 38 | self.assertTrue(self.login_page.is_valid_login_message_displayed()) 39 | self.login_page.click_log_out_button() 40 | self.assertTrue(self.login_page.is_at_login()) 41 | 42 | def test_invalid_login(self): 43 | """Login with invalid credentials, verify invalid login message, try again, verify back at log in.""" 44 | self.login_page.log_in(self.USERNAME, self.INVALID_PASSWORD) 45 | self.assertTrue(self.login_page.is_invalid_login_message_displayed()) 46 | self.login_page.click_try_again_button() 47 | self.assertTrue(self.login_page.is_at_login()) 48 | -------------------------------------------------------------------------------- /tests/tests/native/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-device-farm-appium-python-tests-for-ios-sample-app/f30cba8605eada6b947c931261b537e2479aa53b/tests/tests/native/__init__.py -------------------------------------------------------------------------------- /tests/tests/native/image_gallery_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.tests.base_tests import BaseTest 15 | from tests.pages import ImageGalleryPage 16 | 17 | 18 | class ImageGalleryTest(BaseTest): 19 | """Container for all image gallery page tests.""" 20 | def setUp(self): 21 | """Set up Appium connection and navigate to image gallery page.""" 22 | BaseTest.setUp(self) 23 | BaseTest.navigate_to_page(self) 24 | self.image_gallery_page = ImageGalleryPage(self.driver) 25 | 26 | def get_name(self): 27 | return 'Image Gallery' 28 | 29 | def test_image_gallery(self): 30 | """Verifies image gallery is displayed.""" 31 | self.assertTrue(self.image_gallery_page.image_gallery_is_displayed()) 32 | -------------------------------------------------------------------------------- /tests/tests/native/video_player_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from tests.tests.base_tests import BaseTest 15 | from tests.pages import VideoPlayerPage 16 | 17 | 18 | class VideoPlayerTest(BaseTest): 19 | """Container for all video player page tests.""" 20 | def setUp(self): 21 | """Sets up Appium connection and navigates to video player page.""" 22 | BaseTest.setUp(self) 23 | BaseTest.navigate_to_page(self) 24 | self.video_player_page = VideoPlayerPage(self.driver) 25 | 26 | def get_name(self): 27 | return 'Video Player' 28 | 29 | def test_video_player(self): 30 | """Verifies video player is displayed.""" 31 | self.assertTrue(self.video_player_page.video_is_displayed()) 32 | -------------------------------------------------------------------------------- /tests/tests/nested_views_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from base_tests.base_test import BaseTest 15 | from tests.pages import NestedViewsPage 16 | 17 | 18 | class NestedViewsTest(BaseTest): 19 | """Container for all nested views page tests.""" 20 | FIRST_VIEW_TEXT = 'This is the first view' 21 | SECOND_VIEW_TEXT = 'This is the second view' 22 | THIRD_VIEW_TEXT = 'This is the third view' 23 | FOURTH_VIEW_TEXT = 'This is the fourth view' 24 | 25 | def setUp(self): 26 | """Sets up Appium connection and navigates to nested views page.""" 27 | BaseTest.setUp(self) 28 | BaseTest.navigate_to_page(self) 29 | self.nested_views_page = NestedViewsPage(self.driver) 30 | 31 | def get_name(self): 32 | return 'Nested' 33 | 34 | def test_nested(self): 35 | """Cycles through nested views, verifies text on each page.""" 36 | self.assertEquals(self.nested_views_page.get_static_text(), self.FIRST_VIEW_TEXT) 37 | 38 | self.nested_views_page.click_next_button() 39 | self.assertEquals(self.nested_views_page.get_static_text(), self.SECOND_VIEW_TEXT) 40 | 41 | self.nested_views_page.click_next_button() 42 | self.assertEquals(self.nested_views_page.get_static_text(), self.THIRD_VIEW_TEXT) 43 | 44 | self.nested_views_page.click_next_button() 45 | self.assertEquals(self.nested_views_page.get_static_text(), self.FOURTH_VIEW_TEXT) 46 | 47 | self.nested_views_page.click_back_button() 48 | self.assertEquals(self.nested_views_page.get_static_text(), self.THIRD_VIEW_TEXT) 49 | 50 | self.nested_views_page.click_back_button() 51 | self.assertEquals(self.nested_views_page.get_static_text(), self.SECOND_VIEW_TEXT) 52 | 53 | self.nested_views_page.click_back_button() 54 | self.assertEquals(self.nested_views_page.get_static_text(), self.FIRST_VIEW_TEXT) 55 | -------------------------------------------------------------------------------- /tests/tests/web_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | 14 | from base_tests.base_test import BaseTest 15 | from tests.pages import WebPage 16 | 17 | 18 | class WebTest(BaseTest): 19 | """Container for all web page tests.""" 20 | PAGE_NAME = 'Web' 21 | 22 | def setUp(self): 23 | """Sets up Appium connection and navigates to web page.""" 24 | BaseTest.setUp(self) 25 | BaseTest.navigate_to_page(self) 26 | self.web_page = WebPage(self.driver) 27 | 28 | def get_name(self): 29 | return PAGE_NAME 30 | 31 | def test_web_view(self): 32 | """Verifies web view is displayed.""" 33 | self.assertTrue(self.web_page.web_view_is_displayed()) 34 | --------------------------------------------------------------------------------