Quentin Richarson
Quentin Richarson

Reputation: 13

Separate driver file for browser selenium python base

I tried to have a separate file for browser driver, in my driver file with a file name driver.py:

from selenium import webdriver

class MyDriver():
  def __init__(self):
     self.driver = webdriver.Firefox()

I try reusing it on another file here's the code:

from driver import MyDriver
driver = MyDriver()
driver.get('http://google.com')

However, I always got an error:

AttributeError: 'MyDriver' object has no attribute 'get'

Upvotes: 0

Views: 60

Answers (1)

Ehsan Attar
Ehsan Attar

Reputation: 31

You simply forgot to add another driver. Try this:

driver.driver.get('http://google.com')

Upvotes: 1

Related Questions