Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98974

Create a base driver class and inherit webdriver

$
0
0

In Python/Selenium, I am trying to create a browser class mainly so I can create custom functions like click or type, etc and easily call these by typing something simple such as browser.click(element) or browser.type_text(element, text).

I think I am sort of on the right track but I cannot get the inheritance to work. For example, when I create a browser instance with browser = Browser() and try to use the normal functions of webdriver like browser.get(webpage), I get an error stating that there is no GET function. Am I on the right track here? Is there a better way?

class Browser(webdriver.Chrome):
    def __init__():
        super(self).init()
        self.browser = webdriver.Chrome()

    def click(element):
        WebDriverWait(self, 10).until(EC.element_to_be_clickable(element)).click()

browser = Browser()
element = (By.ID, elements['remember'])
browser.click(element)

Viewing all articles
Browse latest Browse all 98974

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>