我正在使用 Python 中的 merionette 在功能手机上的 Firefox OS 上进行自动化。
我的问题是我无法为某些应用程序上的导航键和其他选择键模拟硬件键事件(在下面的例子中,名称是 ApplicationName)。但是我可以在本机应用程序上使用它们。
下面是我的代码片段:
#creating marionette client on port 2828
client = Marionette('localhost', port=2828)
client.start_session()
#import js script to launch app by name
js = os.path.abspath("/usr/local/script.js")
client.import_script(js)
result=client.execute_async_script("GaiaApps.launchWithName('%s')" % "ApplicationName")
client.switch_to_frame(result.get("frame"))
num = "123456"
client.find_element('css selector','input[type=text]').send_keys(num)
#Above code is working fine
#below code is not working on some thirdparty applications
client.execute_script("window.dispatchEvent(new KeyboardEvent('keydown', {key: 'ArrowDown', keyCode: 40}))")
#closing the client
client.close
可能是什么原因?