2

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

Syscall
  • 16,959
  • 9
  • 22
  • 41
DJQTDJ
  • 65
  • 1
  • 8
  • Possible duplicate of [Selenium WebDriver on IE11 always has "--port=" in URL](https://stackoverflow.com/questions/31831750/selenium-webdriver-on-ie11-always-has-port-in-url) – Amith YR Nov 25 '19 at 09:55
  • Ok, I got that but a new problem is coming out. (This is the initial start page for the WebDriver server.) – DJQTDJ Nov 25 '19 at 10:13
  • You need to navigate to valid url, before that it shows above message by default. Please refer https://sqa.stackexchange.com/questions/3513/ie-always-opens-with-random-local-host-and-message-this-is-the-initial-start-p – Amith YR Nov 25 '19 at 10:17
  • Got that. I set a wrong registry entry(Regedit 64-bit Windows) – DJQTDJ Nov 26 '19 at 05:50

2 Answers2

1

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')
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
0

get() method must have the protocol in url. So you should change:

url = 'www.google.com'

to:

url = 'http://www.google.com'
Yu Zhou
  • 6,874
  • 1
  • 4
  • 20