zoukankan      html  css  js  c++  java
  • selenium 模拟手机

    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

  • 相关阅读:
    论文笔记4
    论文笔记3
    论文笔记2
    论文笔记1
    论文笔记
    AFG与AWG的比较
    Linux下“有线线缆被拔出”问题的解决
    python生成excel格式座位表
    PythonTip--一马当先--bfs
    python pygame--倒计时
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10443997.html
Copyright © 2011-2022 走看看