码迷,mamicode.com
首页 > 移动开发 > 详细

selenium 模拟手机

时间:2019-02-27 15:47:04      阅读:387      评论:0      收藏:0      [点我收藏+]

标签:xxxx   from   galaxy   imp   controls   driver   control   pytho   get   

import time
from selenium import webdriver

mobileEmulation = {‘deviceName‘: ‘Galaxy S5‘}
options = webdriver.ChromeOptions()
options.add_experimental_option(‘mobileEmulation‘, mobileEmulation)

driver = webdriver.Chrome(options=options)
driver.get("http://xxxxxxxx")
time.sleep(3)
driver.close()

  

 

# -*- coding: utf-8 -*-
from selenium import webdriver
from time import sleep

WIDTH = 320
HEIGHT = 640
PIXEL_RATIO = 3.0
UA = ‘Mozilla/5.0 (Linux; Android 4.1.1; GT-N7100 Build/JRO03C) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/35.0.1916.138 Mobile Safari/537.36 T7/6.3‘

mobileEmulation = {"deviceMetrics": {"width": WIDTH, "height": HEIGHT, "pixelRatio": PIXEL_RATIO}, "userAgent": UA}
options = webdriver.ChromeOptions()
options.add_experimental_option(‘mobileEmulation‘, mobileEmulation)

driver = webdriver.Chrome(options=options)
driver.get(‘http://xxxxx‘)

sleep(3)
driver.close()

  

 

https://testerhome.com/topics/9270

 

selenium 模拟手机

标签:xxxx   from   galaxy   imp   controls   driver   control   pytho   get   

原文地址:https://www.cnblogs.com/pythonClub/p/10443997.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!