Selenium launch the Chrome simulator analog phone

Source: Internet
Author: User
Tags selenium grid

First, if the chrome option has this analog device (such as iphone 6 Plus):

1, start selenium Grid first, such as command: Java-jar Selenium-server-standalone-xxx.jar.

2, the code is as follows:

#Coding=utf-8 fromSeleniumImportwebdrivermobile_emulation= {"devicename":"Apple IPhone 6 Plus"}chrome_options=Webdriver. Chromeoptions () chrome_options.add_experimental_option ("mobileemulation", mobile_emulation) driver= Webdriver. Remote (command_executor='Http://127.0.0.1:4444/wd/hub', Desired_capabilities= Chrome_options.to_capabilities ())

Second, if the chrome option is not pre-set the analog device, you can also configure yourself, the code is as follows:

#Coding=utf-8 fromSeleniumImportwebdrivermobile_emulation= {    "Devicemetrics": {"width": 414,"Height": 736,"Pixelratio": 3.0 },    "useragent":"mozilla/5.0 (IPhone; CPU iPhone os 9_1 like Mac os X applewebkit/601.1.46 (khtml, like Gecko) version/9.0 mobile/13b143 safari/601.1"}chrome_options=Webdriver. Chromeoptions () chrome_options.add_experimental_option ("mobileemulation", mobile_emulation) driver= Webdriver. Chrome (chrome_options =chrome_options)

Selenium launch the Chrome simulator analog phone

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.