手机Chrome浏览器访问淘宝H5与在电脑上访问淘宝H5是一摸一样的:
第一种方法:
直接在电脑Chrome浏览器上打开F12:
第二种方法:
手机连接电脑后,
在手机Chrome浏览器上打开淘宝H5,
然后在电脑Chrome浏览器地址栏输入:
chrome://inspect/
点击inspect:
第二种方法好麻烦,
还要翻墙;
推荐用第一种!
ChromeAppTest.py:
import unittest
from time import sleep from appium import webdriver class MyTestCase(unittest.TestCase): def setUp(self):
capabilities = {
"platformName": "Android",
# Mobile OS类型
"platformVersion": "7.1.1",
# Mobile OS版本
"deviceName": "3216e430",
# adb devices
"browserName": "Chrome",
# Chrome浏览器
"appPackage": "com.android.browser",
# Chrome的包名
"appActivity": ".BrowserActivity",
# Chrome的启动页
"unicodeKeyboard": True,
# 支持中文输入,默认false
"resetKeyboard": True,
# 重置输入法为系统默认
"noReset": True,
# 不重新安装apk
"noSign": True
# 不重新签名apk
}
self.driver = webdriver.Remote("http://localhost:4723/wd/hub", capabilities)
sleep(1) def test_chromeApp(self):
url = "https://m.taobao.com"
# 手机淘宝H5
driver = self.driver
driver.get(url)
sleep(1)
driver.find_element_by_id("search-placeholder").click()
# 点击淘宝搜索框
sleep(1)
driver.find_element_by_name("q").send_keys("华硕官方旗舰店")
sleep(1)
driver.find_element_by_class_name("icons-search").click()
sleep(3)
assert driver.page_source.__contains__("asus华硕官方旗舰店") def tearDown(self):
self.driver.close_app()
self.driver.quit() if __name__ == '__main__':
unittest.main()