gpt4 book ai didi

python - 为什么程序总是打开http ://--port=57883/using IEDriverServer IE through Selenium Python

转载 作者:太空宇宙 更新时间:2023-11-03 20:04:44 25 4
gpt4 key购买 nike

代码试验:

import time
from selenium import webdriver
from selenium.webdriver.ie.options import Options
url = 'www.google.com'
def Login():
browser = webdriver.Ie(executable_path=r'C:\Program Files\Internet Explorer\iexplore.exe')
browser.implicitly_wait(5)
browser.get(url)
print(browser.title)
browser.find_element_by_id("register").click()
time.sleep(9)
browser.implicitly_wait(5)
browser.get(url)
time.sleep(9)
browser.quit()

Login()

当我在终端中运行这个python文件时,它总是跳转到名称为(http://--port=57583/)的页面我不知道为什么

<小时/>

20191125添加

browser = webdriver.Ie(executable_path=r'C:\Program Files\Internet Explorer\IEDriverServer.exe')
browser.implicitly_wait(5)
browser.get(url)

当我运行这个login.py时新的错误出现了

Traceback (most recent call last):
File "C:/Users/ou/PycharmProjects/accessw/login.py", line 32, in <module>
ie()
File "C:/Users/ou/PycharmProjects/accessw/login.py", line 14, in ie
browser.get(url)
File "C:\Users\ou\PycharmProjects\accessw\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\ou\PycharmProjects\accessw\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\ou\PycharmProjects\accessw\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: Specified URL (www.google.com) is not valid.
<小时/>

20191126 添加

最后,我花了大约三个小时才弄清楚它出了什么问题!
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE

我需要创建一个名为 iexplore.exe 且值为 0 的 DWORD(32 位)值

最佳答案

可执行文件路径

executable_path是用户可以传递IEDriverServer二进制文件的绝对路径的参数,覆盖IEDriverServer二进制文件的系统路径用于启动 IE session 。

因此,在调用 Key executable_path 时,不要传递 iexplore.exe绝对路径 您需要传递 IEDriverServer.exe绝对路径 如下:

browser = webdriver.Ie(executable_path=r'C:\\Utility\\BrowserDrivers\\IEDriverServer.exe')

关于python - 为什么程序总是打开http ://--port=57883/using IEDriverServer IE through Selenium Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59029032/

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