Appiumシミュレーションログイン

1327 ワード

import os
import unittest

from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction

from time import sleep

# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(__file__), p)
)

class ComplexAndroidTests(unittest.TestCase):
    def setUp(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '6.0'
        desired_caps['deviceName'] = '9999999'
        desired_caps['app'] = PATH(
            'D:\App_TESTNG\apps\BiApp_v1.3.0.apk'
        )

        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

    def tearDown(self):
        self.driver.quit()

    def test_find_elements(self):
        # pause a moment, so xml generation can occur
        sleep(2)

        username = self.driver.find_element_by_xpath("//android.widget.EditText[@text='         ']")
        username.send_keys(25596)
        password = self.driver.find_element_by_xpath("//android.widget.TextView[@text='      ,    ']")
        password.send_keys("23456")