Dinesh Logu
Dinesh Logu

Reputation: 23

Exception in Selenium webdriver(IE) in python

Below is my python code,

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
print("brower1\n")
browser = webdriver.Ie('C:\Program Files (x86)\Internet Explorer\iexplore.exe')
print("brower2\n")

I am getting exception in webdriver.Ie() ,after that print statement print("brower2") is not executing....

Mentioned Below is my exception error,

Traceback (most recent call last):
  File "automated_vpn.py", line 8, in <module>
    browser = webdriver.Ie('C:\Program Files (x86)\Internet Explorer\iexplore.ex
e')
  File "C:\Program Files (x86)\python\lib\site-packages\selenium\webdriver\ie\we
bdriver.py", line 91, in __init__
    self.iedriver.start()
  File "C:\Program Files (x86)\python\lib\site-packages\selenium\webdriver\commo
n\service.py", line 98, in start
    self.assert_process_still_running()
  File "C:\Program Files (x86)\python\lib\site-packages\selenium\webdriver\commo
n\service.py", line 109, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service C:\Program Files
 (x86)\Internet Explorer\iexplore.exe unexpectedly exited. Status code was: 1

please help me out for this issue...

Upvotes: 0

Views: 275

Answers (2)

Nitin_k29
Nitin_k29

Reputation: 351

The path should have double slash or it should have a leading r like r"c:\Program Files(x86)\file.exe"

But the path supplied should be of IE webdriver server and not internet explorer. Download from here and add the path to your environment path variable or supply the full path. This drivers in the mentioned link has been tested with IE 7, 8, 9, 10, and 11 on appropriate combinations of Vista, Windows 7, Windows 8, and Windows 8.1. The 3.9 version of the server is fairly stable but, the latest driver is always recommended. So, it should be

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

The path to IEDriverServer.exe should be included in path.

Now this will work only if

  1. You have same protected mode settings for all internet zones in
    internet explorer. It can be on or off but has to be same for all
    zones.

  2. For IE11 only, there must be a registry value present. For 32-bit Windows HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet
    Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows
    installations, the key is
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet
    Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the
    FEATURE_BFCACHE subkey may or may not be present, and should be
    created if it is not present. Important: Inside this key, create a
    DWORD value named iexplore.exe with the value of 0.

  3. There are known issues with 64 bit IEDriver server, so it is recommended that you use 32 bit server which will automatically launch 32 bit IE browser.

All these requirements are explained here.

Upvotes: 1

Naveen
Naveen

Reputation: 788

Webdriver should be a driver path for the corresponding browser. IE driver files can be found here.

I'd recommed you download the 32-bit IE Driver file, unzip it and place the executable in your program folder and link it like:

browser = webdriver.Ie("C:\\Script path\\IEDriverServer.exe")

Now when you run the script, it should open IE browser.

Upvotes: 1

Related Questions