I am having a bit of trouble with nesting classes in python.
Mind you my code below is a simplified example showing what I want to do, but basically I want to use nested classes to make my code more structured and make sure I don't run into name clashes for certain functions.
See here my example code:
def __init__(self, url='http://localhost:4723/wd/hub'):
capabilities = Capabilities.chrome()
# Start session
self.driver = webdriver.Remote(url, capabilities)
def get_url(self, url):
# Go to URL
# Go to url
if __name__ == '__main__':
browser = Chrome()
if __name__ == '__main__'
You should call
get_url from an instance of
Chrome and not the class itself, since it's an instance method and not a static one:
... @staticmethod def browse_url(url): Chrome().get_url(url) ... if __name__ == '__main__': Chrome.actions.browse_url('https://www.google.com')