Appium app automated testing --- mobile web page testing

Two options:

1. Test mobile web pages through selenium

   (1) A configuration item needs to be added to let the browser recognize that I am accessing through a mobile terminal. The difference is that the UA is different

   (2) There is no difference in other aspects from selenium testing PC browser web pages

from selenium import webdriver

# 添加配置项,让浏览器的UA信息为手机端信息
chromeOption = webdriver.ChromeOptions()
chromeOption.add_experimental_option("mobileEmulation", {"deviceName": "iPhone X"})

# 实例化Chrome驱动对象,参加添加配置项
driver = webdriver.Chrome(r"chromedriver.exe",
                          desired_capabilities=chromeOption.to_capabilities())

# 访问百度首页
driver.get("https://www.baidu.com/")

2. Test the mobile web page through appium

  (1) The configuration information needs to be added:

       'browserName':'Chrome'
       "chromedriverExecutableDir": browser drive path

(2) Configuration information to remove app related information

(3) No other difference

from appium import webdriver

desired_caps = {
    # 平台
    "platformName": "Android",
    "platformVersion": "8",
    "deviceName": "293696c77d22",
    # 被测app的信息
    'browserName': 'Chrome',
    # 浏览器对应驱动路径
    "chromedriverExecutableDir": "D:\personal\project\selenium\chromedriver_74",
    # 设置命令超时时间
    'newCommandTimeout': 6000,
    # 确保自动化之后不重置app
    'noReset': True,
    # 底层驱动
    'automationName': 'UiAutomator2',
    # 如果不想每次都安装UI2驱动,可以这么设置
    'skipServerInstallation': True,

}

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

# 访问百度首页
driver.get("https://www.baidu.com/")

 

Guess you like

Origin blog.csdn.net/qq_19982677/article/details/107699441