【发布时间】:2019-05-24 00:58:44
【问题描述】:
有很多关于使用 Spectron 测试使用 Electron 构建的应用程序的文档。
由于我有很多用 Python 编写的实用程序,我想知道是否有任何方法可以使用 Python-Selenium 来测试在 Electron 中构建的应用程序。
从一些在线资源中,我发现有几个人能够做到这一点(虽然不是我目前使用的最新版本)。 我能够使用下面的代码启动应用程序,但调用 webdriver.Chrome() 是一个阻塞调用,我从来没有得到驱动程序实例:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = "/home/username/electron_test/node_modules/electron/dist/electron"
options.add_argument("--app=/home/username/electron_test/")
driver = webdriver.Chrome(chrome_options=options)
谢谢。
【问题讨论】:
-
stackoverflow.com/a/51186740/8903949。这应该对您有所帮助。我已经尝试使用 java 使用 selenium。
-
我在 python 中使用过类似的代码,但是 webdriver.Chrome() 是一个阻塞调用
-
我认为问题在于“--app=/home/username/electron_test/”行。您能否使用 options.add_argument("--app=","/home/username/electron_test/") 更新它
标签: python selenium electron selenium-chromedriver spectron