Skip to content

Instantly share code, notes, and snippets.

@jerryan999
Created January 3, 2020 02:44
Show Gist options
  • Save jerryan999/1e862c5de50f66292925291231097bd9 to your computer and use it in GitHub Desktop.
Save jerryan999/1e862c5de50f66292925291231097bd9 to your computer and use it in GitHub Desktop.
"""
Qxf2: Example script to run one test against the Chess Free app using Appium
The test will:
- launch the app
- click the 'PLAY!' button
"""
import os
import unittest
from appium import webdriver
from time import sleep
class ChessAndroidTests(unittest.TestCase):
"Class to run tests against the Chess Free app"
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = 'Redmi 3S'
# Returns abs path relative to this file and not cwd
desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'apps/Chess Free.apk'))
desired_caps['appPackage'] = 'uk.co.aifactory.chessfree'
desired_caps['appActivity'] = '.ChessFreeActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
"Tear down the test"
self.driver.quit()
def test_single_player_mode(self):
"Test the Chess app launches correctly and click on Play button"
element = self.driver.find_element_by_id("uk.co.aifactory.chessfree:id/ButtonPlay")
element.click()
sleep(5)
#---START OF SCRIPT
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ChessAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment