0

Having trouble calling the method chrome_configuration that comes from class Profile, I want to call that method on TestBase class:

class TestBase:

     driver = None

     def setup(self):
         Profile.chrome_configuration()


class Profile:

     driver = None

     def chrome_configuration(self):
         self.driver = webdriver.Chrome()
         self.driver.set_window_size(1900, 1200)
         self.driver.maximize_window()

1 Answer 1

1

You must instantiate the class or make the method static. Below are examples of each option.

#By initializing the profile class
class TestBase(object):

     driver = None

     profile = Profile() 

     def setup(self):
         profile.chrome_configuration()

#By making the method static
class Profile(object):

     driver = None

     @staticmethod
     def chrome_configuration(self):
         self.driver = webdriver.Chrome()
         self.driver.set_window_size(1900, 1200)
         self.driver.maximize_window()

In addition, all your classes should always inherit from object in 2.x. It's called new-style classes.

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.