Skip to content

Commit

Permalink
appium test
Browse files Browse the repository at this point in the history
  • Loading branch information
sirkev committed Jun 19, 2024
1 parent 4b936be commit 0a07a62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
53 changes: 19 additions & 34 deletions appium_tests/appium_test.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.options.common.base import AppiumOptions
from appium.webdriver.common.appiumby import AppiumBy
from time import sleep


capabilities = dict(
platformName='Android',
automationName='',
deviceName='Android',
appPackage='com.xysirk3v.example.appium_automation_demo',
appActivity='.MainActivity',
language='en',
locale='US'
)

appium_server_url = 'http://localhost:4723'
options = AppiumOptions()
options.load_capabilities({
"appium:automationName": "UiAutomator2",
"appium:platformName": "Android",
"appium:platformVersion": "10",
"appium:deviceName": "emulator-5554",
"appium:app": "/home/kev/StudioProjects/appium_automation_demo/build/app/outputs/apk/debug/app-debug.apk",
"appium:newCommandTimeout": 3600,
"appium:connectHardwareKeyboard": True
})

class TestAppium(unittest.TestCase):
def setUp(self) -> None:
self.driver = webdriver.Remote(appium_server_url, options=UiAutomator2Options().load_capabilities(capabilities))
driver = webdriver.Remote("http://127.0.0.1:4723", options=options)

def tearDown(self) -> None:
if self.driver:
self.driver.quit()
el1 = driver.find_element(by=AppiumBy.CLASS_NAME, value="android.widget.Button")
el1.click()
el2 = driver.find_element(by=AppiumBy.CLASS_NAME, value="android.widget.Button")
el2.click()
el3 = driver.find_element(by=AppiumBy.CLASS_NAME, value="android.widget.Button")
el3.click()

def test_find_battery(self) -> None:
el = self.driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Battery"]')
el.click()
sleep(5)

er = self.driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Battery percentage"]')
er.click()
sleep(5)





if __name__ == '__main__':
unittest.main()
driver.quit()
7 changes: 7 additions & 0 deletions appium_tests/capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"appium:automationName": "UiAutomator2",
"appium:platformName": "Android",
"appium:platformVersion": "10",
"appium:deviceName": "emulator-5554",
"appium:app": "/home/kev/StudioProjects/appium_automation_demo/build/app/outputs/apk/debug/app-debug.apk"
}

0 comments on commit 0a07a62

Please sign in to comment.