from selenium import webdriver
import unittest
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from time import sleep
class MyTestCase(unittest.TestCase):
def setUp(self) -> None:
self.driver = webdriver.Ie(executable_path="C:\\webdriver\\IEDriverServer.exe")
self.driver.maximize_window()
self.driver.get("https://www.google.ca")
def test_googletest(self):
element = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.NAME, "q")))
element.send_keys("System")
sleep(3)
def tearDown(self):
self.driver.close()
if __name__ == '__main__':
unittest.main()
The code is opening the IE browser successfully but unable to get to google's website. It gets stuck on the localhost in the address bar and after some time it times out. See image below
Below is the error that I get:
Error
Traceback (most recent call last):
File "C:\Users\mahalr\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 60, in testPartExecutor
yield
File "C:\Users\mahalr\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 672, in run
self._callSetUp()
File "C:\Users\mahalr\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 630, in _callSetUp
self.setUp()
File "C:\Users\mahalr\PycharmProjects\TestAutomation\TestAutomation.py", line 13, in setUp
self.driver.get("https://www.google.ca")
File "C:\Users\mahalr\PycharmProjects\TestAutomation\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\mahalr\PycharmProjects\TestAutomation\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\mahalr\PycharmProjects\TestAutomation\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Failed to navigate to https://www.google.ca. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed. The error returned is: Received error: 0x80004005 ['Unspecified error']
Here is my pre-test setup:
- Windows 10 64 bit laptop
- IE Server.exe 32 bit
- IE11
- DWORD key created under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl with a name FEATURE_BFCACHE value = 0
- Enable protected mode checkbox checked for all zones under Internet Options -> Security tab
- Enable 64-bit processes for Enhanced Protected Mode (checked) - This option is disabled and checked as since it is my company laptop
Can someone please guide me as I have hit a wall with this issue and unable to find a resolution?