-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestminesweeper.py
34 lines (28 loc) · 1.35 KB
/
testminesweeper.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
import unittest
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.webdriver.extensions.android.nativekey import AndroidKey
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# {"platformName": "Android", "automationName": "uiautomator2", "deviceName": "Android", "appPackage": "uk.co.whitewillow.minesweepertv", "appActivity": ".MainActivity"}
capabilities = dict(
platformName='Android',
automationName='uiautomator2',
deviceName='Android',
appPackage='uk.co.whitewillow.minesweepertv',
appActivity='.MainActivity'
)
class TestMars(unittest.TestCase):
def setUp(self) -> None:
self.driver = webdriver.Remote('http://localhost:4723', capabilities)
def tearDown(self) -> None:
if self.driver:
self.driver.quit()
def testGamesStateIsStopped(self) -> None:
currentGameStateElement = self.driver.find_element(AppiumBy.XPATH, '//*[@resource-id="currentGameState"]')
self.assertEqual("STOPPED", currentGameStateElement.text)
self.driver.press_keycode(AndroidKey.DPAD_DOWN)
self.assertEqual(currentGameStateElement, self.driver.find_element(AppiumBy.XPATH, '//*[@focused="true"]'))
if __name__ == '__main__':
unittest.main()