我是Appium自动化的初学者,我尝试发送邮件,但是有一些错误,希望有人帮助我。
我使用“ send_keys(“ 0911111111”)“,它只是打印到文本框中,但无法搜索,并且没有搜索按钮。
import unittest
from appium import webdriver
from time import sleep
from appium.webdriver.common.touch_action import TouchAction
# 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 ContactsAndroidTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
#desired_caps['automationName'] = 'UiAutomator1'
desired_caps['platformVersion'] = '10.0'
desired_caps['udid'] = '8BLAY00DSD'
desired_caps['deviceName'] = 'Pixel 3a'
#desired_caps['app'] = PATH('D:/appium/app/ContactManager.apk')
desired_caps['appPackage'] = 'com.google.android.apps.messaging'
desired_caps['appActivity'] = '.ui.ConversationListActivity'
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
def tearDown(self):
sleep(1)
self.driver.quit()
def test_text_friend(self):
search_button = self.driver.find_element_by_id("com.google.android.apps.messaging:id/action_zero_state_search").click()
name_search_bar = self.driver.find_element_by_id("com.google.android.apps.messaging:id/zero_state_search_box_auto_complete")
name_search_bar.send_keys("0911111111")
driver.press_keycode(84)
if __name__ == '__main__':
suite =
unittest.TestLoader().loadTestsFromTestCase(ContactsAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)