Appium-Python-Client 4.+版本踩坑實錄

backlightズ發表於2024-06-20
  • Appium-Python-Client 4.+ 版本 TouchAction類 被 appium.webdriver.extensions.action_helpers.ActionHelpers 取代
    • 使用方法
      # 點選座標
      self.driver.tag(positions, duration=duration)
      # 螢幕元素滑動
      self.driver.scroll(origin_el=origin_el, destination_el=destination_el, duration=duration)
      # 拖動元素
      self.driver.drag_and_drop(origin_el=origin_el, destination_el=destination_el, pause=duration)
      # 滑動螢幕
      self.driver.swipe(start_x=x1, start_y=y1, end_x=x1, end_y=y2, duration=duration)
  •  appium-doctor報 bundletool.jar cannot be found
    • 下載bundletool.jar,配置環境變數
    • 若還報錯,在 PATHEXT 新增 .JAR

  • Appium python連結方式變更
    from appium import webdriver as app
    from appium.options.android import UiAutomator2Options
    
     desired_caps = {
                    "platformName": PlatformName,
                    "deviceName": DeviceName,
                    # 啟動app
                    "appPackage": AppPackage,
                    "appActivity": AppActivity,
                    # 不重置app
                    "noReset": NoReset,
                    # 隱藏手機預設鍵盤
                    "unicodeKeyboard": UnicodeKeyboard,
                    "resetKeyboard": ResetKeyboard,
                    "appium:newCommandTimeout": NewCommandTimeout,
                    "appium:automationName": AutomationName
    
                }
    # 關聯appium
    driver = app.Remote("http://127.0.0.1:4723/wd/hub", options=UiAutomator2Options().load_capabilities(desired_caps))

相關文章