我有一个小节点/电子应用程序要测试。
它只是使用“npm start”在本地运行,它会打开一个带有应用程序的小型电子浏览器。
鉴于我没有提供的网址,我如何使用 pytest-selenium 进行测试?
理想情况下,我更喜欢使用 selenium 夹具。
这是我到目前为止所拥有的。
def test_sanity(install_cbm_dash, install_dir):
from selenium import webdriver
# Start the web driver
web_driver_path = "C:\\webdrivers\\chromedriver.exe"
service = webdriver.chrome.service.Service(web_driver_path)
service.start()
# start the app
web_driver = webdriver.remote.webdriver.WebDriver(
command_executor=service.service_url,
desired_capabilities={
'browserName': 'chrome',
'goog:chromeOptions': {
'args': [],
'binary': "path_to_electron_exe",
'extensions': [],
'windowTypes': ['webview']},
'platform': 'ANY',
'version': ''},
browser_profile=None,
proxy=None,
keep_alive=False)
这会打开一个电子窗口,但不会打开相关应用程序。我如何引导它打开实际的应用程序?
我想我需要指定项目本身到电子的路径,但我不知道该怎么做。