如何使用Selenium自动化Firefox Mobile? [英] How to automate Firefox Mobile with Selenium?

查看:923
本文介绍了如何使用Selenium自动化Firefox Mobile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

  1. Appium (两个).
  2. Firefox桌面具有内置的
  3. Geckodriver 似乎不支持Firefox移动版.与 Chromedriver 相比,Geckodriver没有专门针对移动设备的代码.
  4. (或曾经有)使用Firefox打开移动设备仿真的方法偏好.通过使用Marionette API调用将Firefox从CONTENT切换到CHROME上下文,然后使用Selenium按下键盘快捷键来进行工作.
  1. Firefox Mobile is not supported in Appium (one, two).
  2. Firefox Desktop has built-in
  3. It seems that Geckodriver does not support Firefox mobile. Compared to Chromedriver Geckodriver has no mobile-specific code.
  4. There is (or there was) some way to open mobile emulation using Firefox prefs. It works by switching Firefox from CONTENT to CHROME context using Marionette API calls and then pressing keyboard shortcut with Selenium.

使用任何这些解决方案都无法成功.知道如何自动化Firefox Mobile吗?

Did not manage to succeed with any of these solutions. Any idea how to automate Firefox Mobile?

推荐答案

您可以尝试通过使用Geckodriver并更改用户代理和设备大小(宽度和高度)在FireFox Desktop应用程序上模拟它.这是Python 3中的示例:

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)

这篇关于如何使用Selenium自动化Firefox Mobile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆