我需要在Firefox Mobile中运行Selenium测试。有谁可以形容一个简单的方法来做到这一点?我的调查表明:
无法通过任何这些解决方案取得成功。知道如何自动化Firefox Mobile吗?
答案 0 :(得分:1)
您可以尝试使用Geckodriver并更改用户代理和设备大小(宽度和高度)在FireFox桌面应用上模拟它。这是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)
答案 1 :(得分:0)
binary = FirefoxBinary('geckodriver.exe')
capabilities = {
'browserName': 'firefox',
'firefoxOptions': {
'mobileEmulation': {
'deviceName': 'iPhone X'
}
}
}
browser = webdriver.Firefox(firefox_binary=binary, desired_capabilities=capabilities)
这应该有效。 Havent已对其进行了测试,请尝试并让我知道。