pythonseleniuminternet-explorerselenium-iedriveriedriverserver

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


20191125 ADD

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

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

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


Solution

  • 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.

    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:

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