0

I am new to Selenium/Python and practicing few exercises. I am receiving below error when running my Selenium/Python program in pycharm. Please help.

C:\Users\rk.marav\PycharmProjects\RadhaSelenium\venv\Scripts\python.exe C:/Users/rk.marav/PycharmProjects/RadhaSelenium/Tests/mainTest.py
Traceback (most recent call last):
  File "C:/Users/rk.marav/PycharmProjects/RadhaSelenium/Tests/mainTest.py", line 13, in <module>
    m.main()
  File "C:/Users/rk.marav/PycharmProjects/RadhaSelenium/Tests/mainTest.py", line 10, in main
    driver.getbrowserInstance()
  File "C:\Users\rk.marav\PycharmProjects\RadhaSelenium\executionEngine\DriverScript.py", line 25, in getbrowserInstance
    driver = webdriver.ie(executable_path='C:/Selenium/Drivers/IEDriverServer.exe')
TypeError: 'module' object is not callable
Main Test started...
IE
Browser invoke started

Process finished with exit code 1

Below is my code:

DriverScript.py:

class driverScript:

    def __init__(self,browser=None):
         if browser is None:
             browser = {}
         else:
             self.browser = browser
             print(self.browser)

         #self.constants = Constants()

    def getbrowserInstance(self):
        # create a new IE session
        print("Browser invoke started")
        if (self.browser=='IE'):
           driver = webdriver.ie(executable_path='C:/Selenium/Drivers/IEDriverServer.exe')
           driver.maximize_window()
           driver.implicitly_wait(5)
           driver.delete.allcookies()
           print("Browser is Invoked")
           driver.get("http://www.store.demoqa"
                       ".com")

mainTest.py

from executionEngine.DriverScript import driverScript
from Utilities.Constants import Constants
from selenium import webdriver

class mainTest(driverScript):

    def main(self):
        print("Main Test started...")
        driver = driverScript('IE')
        driver.getbrowserInstance()

m = mainTest()
m.main()
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
murthymrk
  • 51
  • 1
  • 2
  • 10

1 Answers1

0

This error message...

    driver = webdriver.ie(executable_path='C:/Selenium/Drivers/IEDriverServer.exe')
TypeError: 'module' object is not callable

...implies that the webdriver.ie is a module and is not callable.

@JohnGordon was pretty correct in his analysis. selenium.webdriver.ie.webdriver is one of the Selenium related Python Module and is not callable.

To initiate an session through you need to replace the small i with capital I. So effectively your line of code will be:

driver = webdriver.Ie(executable_path=r'C:\Selenium\Drivers\IEDriverServer.exe')

You can find a relevant discussion in TypeError: 'module' object is not callable error with driver=webdriver(“C:\Python34\Lib\site-packages\selenium\webdriver\chromedriver.exe”)

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352