|
| 1 | +#!/usr/bin/env python |
| 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 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import unittest |
| 16 | + |
| 17 | +from appium import webdriver |
| 18 | +from appium.common.exceptions import NoSuchContextException |
| 19 | +import desired_capabilities |
| 20 | +from time import sleep |
| 21 | + |
| 22 | +from selenium.webdriver.common.touch_actions import TouchActions |
| 23 | + |
| 24 | + |
| 25 | +class SelendroidTests(unittest.TestCase): |
| 26 | + def setUp(self): |
| 27 | + desired_caps = desired_capabilities.get_desired_capabilities('ApiDemos-debug.apk') |
| 28 | + desired_caps['automationName'] = 'Selendroid' |
| 29 | + self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) |
| 30 | + |
| 31 | + def test_contexts_list(self): |
| 32 | + el = self.driver.find_element_by_class_name('android.widget.ListView') |
| 33 | + els = el.find_elements_by_class_name('android.widget.TextView') |
| 34 | + |
| 35 | + ta = TouchActions(self.driver).flick_element(el, 0, -300, 0) |
| 36 | + ta.perform() |
| 37 | + sleep(5) |
| 38 | + |
| 39 | + def tearDown(self): |
| 40 | + self.driver.quit() |
| 41 | + |
| 42 | + def _enter_webview(self): |
| 43 | + btn = self.driver.find_element_by_name('buttonStartWebviewCD') |
| 44 | + btn.click() |
| 45 | + self.driver.switch_to.context('WEBVIEW') |
| 46 | + |
| 47 | + |
| 48 | +if __name__ == "__main__": |
| 49 | + suite = unittest.TestLoader().loadTestsFromTestCase(SelendroidTests) |
| 50 | + unittest.TextTestRunner(verbosity=2).run(suite) |
0 commit comments