I am trying to call get_driver_path inside __new__ method, and I get this error when I try to run the full code:
TypeError: unbound method get_chrome_driver() must be called with
WebBrowserManager instance as first argument (got str instance instead
Here is the code:
def __new__(self, driver = 'firefox'):
if not self._instance:
self._instance = super(WebBrowserManager, self).__new__(self)
self._profile.native_events_enabled = True
self.data = {}
self._system = platform.system()
if self._local:
if driver == 'firefox':
self.browser = webdriver.Firefox(self._profile)
elif driver == 'chrome':
self.browser = self.get_chrome_driver(self._system, driver)
elif driver == 'ie':
assert self._system == 'Windows', 'Tests on Internet Explorer are only supported on Windows'
self.browser = webdriver.Ie(self.get_driver_path(driver))
return self._instance
def get_driver_path(self, driver):
driver_name = ''
if driver == 'ie':
driver_name = 'IEDriverServer.exe'
elif driver == 'chrome':
driver_name = 'chromedriver.exe'
driver_path = "selenium_drivers\\" + driver_name
os.environ["webdriver." + driver + ".driver"] = driver_path
return driver_path