How to automate Firefox Mobile with Selenium?

前端 未结 2 1670
别那么骄傲
别那么骄傲 2021-01-19 04:39

I need to run Selenium tests in Firefox Mobile. Could anybody describe an easy way to do this? My investigation shows that:

  1. Firefox Mobile is not supported in
相关标签:
2条回答
  • 2021-01-19 05:05
    binary = FirefoxBinary('geckodriver.exe')
    capabilities = {
        'browserName': 'firefox',
        'firefoxOptions': {
            'mobileEmulation': {
                'deviceName': 'iPhone X'
            }
        }
    }
    
    browser = webdriver.Firefox(firefox_binary=binary, desired_capabilities=capabilities)
    

    This should work. Havent tested it so try it and let me know.

    0 讨论(0)
  • 2021-01-19 05:22

    You can try to emulate it on the FireFox Desktop app by using Geckodriver and changing User Agent and device size (width and height). Here is an example in Python 3:

    user_agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16"
    
    profile = webdriver.FirefoxProfile() 
    profile.set_preference("general.useragent.override", user_agent)
    driver = webdriver.Firefox(profile)
    driver.set_window_size(360,640)
    
    0 讨论(0)
提交回复
热议问题