Byy
29
import pytest
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
class Test_Appium:
def setup(self):
desired_caps = {}
desired_caps['platformName'] = 'android'
desired_caps['deviceName'] = 'emulator-5554'
desired_caps['appPackage'] = 'com.tencent.wework'
desired_caps['appActivity'] = 'com.tencent.wework.launch.WwMainActivity'
desired_caps['noReset'] = 'true'
desired_caps['autoGrantPermissions']='true'
desired_caps['skipDeviceInitialization']='true'
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
self.driver.implicitly_wait(5)
def teardown(self):
self.driver.quit()
@pytest.mark.parametrize('name,mes',[('a1','mes1')])
def test_1(self,name,mes):
self.driver.find_element(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/dnj' and @text='通讯录']").click()
self.driver.find_element(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/gq_']").click()
self.driver.find_element(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/ffq']").send_keys(name)
WebDriverWait(self.driver,5).until(expected_conditions.element_to_be_clickable((MobileBy.XPATH,"//*[@resource-id='com.tencent.wework:id/de1']")))
self.driver.find_element(MobileBy.XPATH,"//*[@resource-id='com.tencent.wework:id/de1']").click()
self.driver.find_element(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/aam']").click()
self.driver.find_element(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/dtv']").click()
self.driver.find_element(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/dtv']").send_keys(mes)
self.driver.find_element(MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/dtr']").click()