使用selenium/chromedriver测试CEF3嵌入式应用程序的Python脚本无法在127.0.0.1:4444连接到chrome

2024-10-03 13:22:27 发布

您现在位置:Python中文网/ 问答频道 /正文

该应用程序是一个嵌入式CEF3C\MS Windows应用程序,它启用了远程调试器地址。我遵循了java示例,可以使用javaprg控制应用程序。然而,我们使用Python作为主要的测试自动化语言,我尝试在Python中实现相同的代码,但是我得到一个“无法连接到chrome的127.0.0.1:4444”。 我错过了什么:

import selenium
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
import os

os.environ["webdriver.chrome.driver"] = "D:/dev/desktop-automation/selenium/chromedriver.exe"
chromeOps = webdriver.ChromeOptions()
chromeOps.binary_location = "C:/Program Files (x86)/Path to application/Application.exe"
chromeOps.debugger_address = "127.0.0.1:4444"
browser = webdriver.Chrome(chrome_options=chromeOps)

time.sleep(3)
browser.get("http://example.com")

非常感谢你的帮助!在


Tags: fromimportbrowser应用程序timeoswindowsselenium
1条回答
网友
1楼 · 发布于 2024-10-03 13:22:27

缺少的位是在运行脚本之前设置此值: 设置webdriver.chrome.driver=“D:/dev/desktop automation/selenium公司/chromedriver.exe" 看来操作系统环境不为正在运行的脚本设置此值。在

相关问题 更多 >