gpt4 book ai didi

selenium - 使用Selenium ChromeDriver时Electron无法访问用户数据目录

转载 作者:行者123 更新时间:2023-12-03 12:32:42 25 4
gpt4 key购买 nike

我将Selenium与Robot Framework一起使用来运行Electron应用程序。构建该应用程序是为了从用户数据目录中读取配置文件。据我了解,这是该文件的存储位置。
Electron 主程序读取配置文件:

const localConfigFile = path.join(app.getPath('userData'), 'config.json');
const localConfig = fs.existsSync(localConfigFile) ? require(localConfigFile) : {};
生成的生产版本可以正常工作,并且可以按预期读取文件,但是使用SeleniumLibrary从Robot启动文件时,不会读取该文件。这使我相信这是Robot,Selenium或ChromeDriver的问题。
机器人使用SeleniumLibrary创建webdriver:
Create Webdriver    Remote    desired_capabilities=${starting_parameters}    command_executor=http://127.0.0.1:9515
起始参数很简单:
{ "chromeOptions": {"binary": <binary_location> }}
Chromedriver是从安装 /usr/bin/chromedriver的独立过程启动的,并使用默认端口 9515
我使用的版本是:
ChromeDriver 2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752)
"electron": "^6.0.2"
"electron-builder": "^21.2.0"
robotframework==3.2.1
robotframework-seleniumlibrary==3.3.1
Ubuntu 18.04.4 LTS

最佳答案

遇到过同样的问题。最后,将Chromedriver的user-data-dir参数更改为Electron的userDataDir解决了该问题。
options.add_argument('-user-data-dir ='+ str(app_config_path()))

关于selenium - 使用Selenium ChromeDriver时Electron无法访问用户数据目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64172096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com