-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_apidemo.py
59 lines (45 loc) · 2.56 KB
/
test_apidemo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pytest
import unittest
from appium import webdriver
from time import sleep
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support.wait import WebDriverWait
class TestApiDemo(unittest.TestCase):
def setUp(self):
print("setup")
caps = {}
caps["platformName"] = "android"
caps["deviceName"] = "demo"
#caps["appPackage"] = "com.example.android.apis"
caps["appPackage"] = "io.appium.android.apis"
caps["appActivity"] = ".ApiDemos"
caps["autoGrantPermissions"] = "true"
caps["automationName"] = "UiAutomator2"
caps["newCommandTimeout"] = 600
self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
self.driver.implicitly_wait(10)
def test_toast(self):
self.driver.find_element_by_accessibility_id("Views").click()
#self.driver.find_element_by_accessibility_id("Popup Menu").click()
self.driver.find_element_by_android_uiautomator(
'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "Popup Menu")'
).click()
self.driver.find_element_by_accessibility_id("Make a Popup!").click()
self.driver.find_element_by_xpath("//*[@text='Search']").click()
print(self.driver.find_element_by_xpath("//*[@class='android.widget.Toast']").text)
print(self.driver.find_element_by_xpath("//*[@package='com.android.settings']").text)
print(self.driver.find_element_by_xpath("//*[contains(@text, 'Clicked')]").text)
def test_toast_not_found(self):
self.driver.find_element_by_accessibility_id("Views").click()
#self.driver.find_element_by_accessibility_id("Popup Menu").click()
self.driver.find_element_by_android_uiautomator(
'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "Popup Menu")'
).click()
self.driver.find_element_by_accessibility_id("Make a Popup!").click()
self.driver.find_element_by_xpath("//*[@text='Search']").click()
def test_webview_sim_simple(self):
self.driver.find_element_by_accessibility_id("Views").click()
self.driver.find_element_by_android_uiautomator(
'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "WebView")'
).click()
self.driver.find_element_by_accessibility_id("Hello World! - 1").click()