时间从D盘time.txt获取。
This commit is contained in:
@@ -48,10 +48,37 @@ def init_appium_driver(device_id, app_package="com.bjjw.cjgc", app_activity=".ac
|
||||
|
||||
try:
|
||||
# 连接Appium服务器
|
||||
driver_url = "http://127.0.0.1:4723/wd/hub"
|
||||
logging.info(f"设备 {device_id} 正在连接Appium服务器: {driver_url}")
|
||||
driver = webdriver.Remote(driver_url, options=options)
|
||||
logging.info(f"设备 {device_id} Appium服务器连接成功")
|
||||
# driver_url = "http://127.0.0.1:4723/wd/hub"
|
||||
# logging.info(f"设备 {device_id} 正在连接Appium服务器: {driver_url}")
|
||||
# driver = webdriver.Remote(driver_url, options=options)
|
||||
# logging.info(f"设备 {device_id} Appium服务器连接成功")
|
||||
driver_urls = [
|
||||
"http://127.0.0.1:4723/wd/hub", # 标准路径
|
||||
"http://127.0.0.1:4723", # 简化路径
|
||||
"http://localhost:4723/wd/hub", # localhost
|
||||
]
|
||||
|
||||
driver = None
|
||||
last_exception = None
|
||||
|
||||
# 尝试多个URL
|
||||
for driver_url in driver_urls:
|
||||
try:
|
||||
logging.info(f"设备 {device_id} 正在连接Appium服务器: {driver_url}")
|
||||
driver = webdriver.Remote(driver_url, options=options)
|
||||
logging.info(f"设备 {device_id} Appium服务器连接成功: {driver_url}")
|
||||
break # 连接成功,跳出循环
|
||||
except Exception as e:
|
||||
last_exception = e
|
||||
logging.warning(f"设备 {device_id} 连接失败 {driver_url}: {str(e)[:100]}")
|
||||
continue
|
||||
|
||||
# 检查是否连接成功
|
||||
if not driver:
|
||||
logging.error(f"设备 {device_id} 所有Appium服务器地址尝试失败")
|
||||
logging.error(f"最后错误: {str(last_exception)}")
|
||||
raise Exception(f"设备 {device_id} 无法连接到Appium服务器: {str(last_exception)}")
|
||||
|
||||
|
||||
# 初始化等待对象
|
||||
wait = WebDriverWait(driver, 20)
|
||||
@@ -679,6 +706,7 @@ def go_main_click_tabber_button(driver, device_id, tabber_button_text, max_retri
|
||||
tabber_button = driver.find_element(AppiumBy.ID, tabber_button_text)
|
||||
# 点击按钮
|
||||
tabber_button.click()
|
||||
tabber_button.click()
|
||||
logging.info(f"设备 {device_id} 已成功点击导航菜单按钮: {tabber_button_text}")
|
||||
|
||||
# 等待页面加载
|
||||
|
||||
Reference in New Issue
Block a user