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()
5
  • 2
    webdriver.ie is a module. You're calling the wrong thing. You want webdriver.Ie instead (note the capital I.) See stackoverflow.com/a/24925868/494134 for more details. Commented Jan 8, 2020 at 16:24
  • 1
    Capital letters matter Commented Jan 8, 2020 at 16:28
  • why don't you inherit the class Selenium? Commented Jan 8, 2020 at 16:45
  • 1
    Variable and function names should follow the lower_case_with_underscores style. I’m voting to close this since it appears to be a typo/trivial. Commented Jan 8, 2020 at 17:12
  • Thanks John. Very much appreciated. Thats resolved the issue. Commented Jan 9, 2020 at 10:45

1 Answer 1

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”)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.