两种方案:
1.通过selenium测试移动端web网页
(1)需要添加配置项,让浏览器识别到我是通过移动端来访问的,区别是UA的不同
(2)其他方面跟selenium测试PC端浏览器网页没有区别
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.通过appium测试移动端web网页
(1) 配置信息需要添加:
'browserName': 'Chrome'
"chromedriverExecutableDir":浏览器驱动路径
(2)配置信息移除app相关信息
(3)其他无差异
from appium import webdriver
desired_caps