TestProject Forum
Powered by leading experts in the test automation community

Appium cannot perform APP operations on the emulator

You can run appium by yourself, but you can’t run it through Testproject.

#appium
from src.testproject.sdk.drivers import webdriver
#用來等待元素控件 (WebDiverWait)
from selenium.webdriver.support.ui import WebDriverWait
#等待時間
from time import sleep

caps = {}
caps[‘deviceName’] = ‘127.0.0.1:62001’ #adb devices連接之設備成稱
caps[‘platformName’] = ‘Android’ #作業系統
caps[‘platformVersion’] = ‘5.1.1’ #系統版本
caps[‘appPackage’] = ‘com.momo.mobile.shoppingv2.android’ #預自動化連接APP的包
caps[‘appActivity’] = ‘.modules.home.v2.HomeActivity’ #預自動化連接APP的活動
driver = webdriver.Remote(desired_capabilities=caps)
#10秒內每0.5秒(默認)重複搜尋,直到找到返回值
element = WebDriverWait(driver, 10).until(
lambda x: x.find_element_by_id(‘com.momo.mobile.shoppingv2.android:id/md_buttonDefaultPositive’))
element.click()

sleep(10)
driver.quit()

my code

This is the simulator I originally executed

Hello, like we discussed over in the chat, the main issue here is the SDK returns the incorrect message if the device is not found, I have opened an issue on that.