[英]Why does the program always open http://--port=57883/ using IEDriverServer IE through Selenium Python
Code trials:代码试验:
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()
when I run this python file in terminal, it always jumps to the page which names (http://--port=57583/) and I don't know why当我在终端中运行这个 python 文件时,它总是跳转到命名 (http://--port=57583/) 的页面,我不知道为什么
browser = webdriver.Ie(executable_path=r'C:\Program Files\Internet Explorer\IEDriverServer.exe')
browser.implicitly_wait(5)
browser.get(url)
when I run this login.py the new error is coming out当我运行这个 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.
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BFCACHE HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BFCACHE
I need to create a DWORD(32bit both) value named iexplore.exe with the value of 0我需要创建一个名为 iexplore.exe 的 DWORD(32 位)值,值为 0
executable_path is the parameter through which users can pass the absolute path of the IEDriverServer binary overriding the system path of IEDriverServer binary to be used to initiate an IE session. executable_path是通过它用户可以通过IEDriverServer的绝对路径二进制重写IEDriverServer二进制的系统路径将被用于启动一个IE会话参数。
So while invoking the Key executable_path , instead of passing the absolute path of the iexplore.exe
you need to pass the absolute path of the IEDriverServer.exe
as follows:因此,尽管调用重点executable_path,而不是传递的绝对路径
iexplore.exe
你需要传递的绝对路径IEDriverServer.exe
如下:
browser = webdriver.Ie(executable_path=r'C:\\Utility\\BrowserDrivers\\IEDriverServer.exe')
get()
method must have the protocol in url. get()
方法必须在 url 中有协议。 So you should change:所以你应该改变:
url = 'www.google.com'
to:到:
url = 'http://www.google.com'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.