如何使用 Selenium 自动化 Firefox Mobile?

van*_*ooh 5 firefox mobile selenium browser-automation

我需要在 Firefox Mobile 中运行 Selenium 测试。有人可以描述一个简单的方法来做到这一点吗?我的调查表明:

  1. Appium不支持 Firefox Mobile ()。
  2. Firefox Desktop 内置了响应式设计模式,如图所示:响应式用户界面模式
  3. 看来,Geckodriver不支持Firefox移动。与Chromedriver相比,Geckodriver没有特定于移动设备的代码。
  4. 这里(或有)一些方法来打开使用Firefox的首选项移动模拟。它的工作原理是使用 Marionette API 调用将 Firefox 从 CONTENT 切换到 CHROME 上下文,然后使用 Selenium 按下键盘快捷键。

这些解决方案中的任何一个都没有成功。知道如何自动化 Firefox Mobile 吗?

Haw*_*ett 6

您可以尝试通过使用 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)
Run Code Online (Sandbox Code Playgroud)