当前位置:   article > 正文

appium的代码逻辑_appium option

appium option
  1. from appium import webdriver
  2. from appium.webdriver.common.touch_action import TouchAction
  3. desired_capacity = {}
  4. desired_capacity["platformName"] = "Android"
  5. desired_capacity["deviceName"] = "JVGUOVCA9H5PEEDI"
  6. desired_capacity["platformVersion"] = "6.0"
  7. desired_capacity["appPackage"] = "com.tencent.mm"
  8. desired_capacity["appActivity"] = "com.tencent.mm.ui.LauncherUI"
  9. desired_capacity["noReset"] = True
  10. driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_capacity)
  11. driver.implicitly_wait(10)
  12. me_ele = driver.find_elements_by_id("com.tencent.mm:id/ddk")[3]
  13. TouchAction(driver).tap(me_ele).perform()
  14. pay_ele = driver.find_elements_by_id("com.tencent.mm:id/a0c")[0]
  15. TouchAction(driver).tap(pay_ele).perform()

desired_capacity["noReset"] = True 表示会话保留,即当app登录之后,appium就不会再去重新登录了。

desired_capacity["deviceName"] = "JVGUOVCA9H5PEEDI" 使用adb devices可以查看deviceName。

adb connect 62001 连接手机或模拟器的端口号。

而对于selenium的会话保存,是使用cookie进行操作的,这样,在请求web页面的时候,将cookie传递过去,就会达到已经登录的状态了。

  1. from selenium import webdriver
  2. options = webdriver.ChromeOptions()
  3. options.add_argument('lang=zh_CN.UTF-8')
  4. options.add_argument('user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1"')
  5. driver = webdriver.Chrome(chrome_options = options)

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/364496
推荐阅读
  

闽ICP备14008679号