near Time Test H5 page, use Chrome browser and then F12 switch to phone mode, just start using selenium frame and then simulate Operation F12, but found that switch to phone mode and then return to the original browser mode , later on a variety of Baidu, finally found the answer, the following is the sample code # -*- coding: utf-8 -*-from selenium import Webdriverfrom time import sleepprotocol= ' http ' url=protocol+ '://m.baidu.com ' mobileEmulation = {' devicename ': ' iphone 6 '}options = webdriver. Chromeoptions () options.add_experimental_option (' mobileemulation ', mobileemulation) driver = Webdriver. Chrome (executable_path= ' Chromedriver.exe ', chrome_options=options) driver.get (URL) class openh5 (): def openbaidu (self): #driver = self.driver print "Tap input Box" driver.find_element_by_id ("index-kw"). Clear ()      DRIVER.FIND_ELEMENT_BY_ID ("Index-kW "). Send_keys (U" Test ") driver.find_element_by_id ("Index-bn"). Click () driver.get_ Screenshot_as_file (".. /.. /screen/chaweizhang.png ") sleep (3) #driver. Find_element_by_xpath (".//*[@id = ' app ']/div/div/div[3]/ul/li[3]/span[text () = ' Activity ']. Click () print u ' Close browser ' driver.quit () login1 =openh5 () Login1.openbaidu () sleep (5)
Chrome Analog Mobile Browser Python+selenium