简体   繁体   English

为什么程序总是通过Selenium Python使用IEDriverServer IE打开http://--port=57883/

[英]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/) 的页面,我不知道为什么


20191125 ADD 20191125 添加

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.

20191126 ADD 20191126 添加

Finally, it took me about three hours to figure out What's wrong with it ! 最后,我花了大约三个小时才弄清楚它有什么问题!
 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可执行路径

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.

相关问题 如何通过 Selenium 和 Python 中的 IEDriverServer 使用 DesiredCapabilities 类 - How to use DesiredCapabilities class through IEDriverServer in Selenium and Python 无法通过 Python 使用 IEDriverServer 和 Selenium 提取页面标题和 page_source - Unable to extract page tittle and page_source using IEDriverServer and Selenium through Python 无法在python中使用selenium打开IE - Can't open IE using selenium in python 为什么 Selenium 的程序总是自动跳转到我的桌面 - Why does the Selenium's program always automatically jump to my desktop 如何让 selenium 在通过 IEDriverServer 和 IE 从登陆页面后加载的实际网站获取内容之前等待 - How to make selenium wait before getting contents from the actual website which loads after the landing page through IEDriverServer and IE 硒Python在IE浏览器上打开 - Selenium Python open on IE browser 当我使用IE作为驱动程序运行此Selenium / WebDriver代码时,为什么python.exe崩溃? - Why does python.exe crash when I run this Selenium/WebDriver code using IE as the driver? 使用python和selenium在IE中打开一个Url,在IE中切换 - Open a Url in new tab and tab switching in IE using python and selenium Python3 Portscanner 无法识别打开的端口 80,但始终识别端口 22 - Python3 Portscanner does not recognize open Port 80, but Port 22 always selenium.common.exceptions.TimeoutException:消息:通过 Selenium 使用 IEDriverServer 和 Internet Explorer 等待页面加载超时 - selenium.common.exceptions.TimeoutException: Message: Timed out waiting for page to load using IEDriverServer and Internet Explorer through Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM