fabio
fabio

Reputation: 1365

Implicitly_wait() missing 1 required positional argument

I'm studying selenium with python and in a tutorial I found the following code.

from selenium import webdriver
from time import gmtime, strftime
import unittest
#from builtins import classmethod

class RegisterNewUser(unittest.TestCase):
    #@classmethod
    def setUp(self):
        self.driver = webdriver.Firefox
        self.driver.implicitly_wait(30)
        self.driver.maximize_window()

        # navigate to the application home page
        self.driver.get("http://demo-store.seleniumacademy.com/")

    def test_register_new_user(self):
        driver = self.driver
        pass

    def tearDown(self):
        self.driver.quit()

if __name__ == "__main__":
    unittest.main(verbosity=2)

It throw an error:

File "register_new_user.py", line 10, in setUp
    self.driver.implicitly_wait(30)
TypeError: implicitly_wait() missing 1 required positional argument: 'time_to_wait'

I try to add the code commented out (classmethod) but doesn't change anything. Without the test_register_new_user doesn't give error.

I'm using python 3.6.4, selenium 3.141 (and geckodriver 0.23)

Upvotes: 0

Views: 1523

Answers (1)

DeepSpace
DeepSpace

Reputation: 81654

Your problem is one line above:

self.driver = webdriver.Firefox

This does not create a browser object. It just sets self.driver to the class webdriver.Firefox, which means that self.driver.implicitly_wait(30) is trying to use implicitly_wait in the static way, ie webdriver.Firefox.implicitly_wait(30), so it is missing the instance, ie webdriver.Firefox.implicitly_wait(an_actual_browser, 30).

You are missing ():

self.driver = webdriver.Firefox()  # which will potentially ask for a path to 
                                   # firefox/geckodriver if it is not in PATH, 
                                   # but that is out of the scope of this question

Upvotes: 3

Related Questions