Reputation: 538
I am experimenting with Selenium (3.141.0) using Python 3.7 and chromedriver (2.45.615291) and am getting the following error.
TypeError: get() missing 1 required positional argument: 'url'.
Main code:
from session import browser
from authentication import consolelogin as cl
from selenium.webdriver.firefox.options import Options
from selenium import webdriver
#select driver
driver = webdriver.Chrome
#define options for session
options = Options()
options.set_headless(False)
options.set_capability("pageLoadStrategy","none")
options.binary_location = "file_location"
#create a session object
session = browser.session(driver=driver,options=options)
session.launch()
#login to google
Google = cl.GoogleLogin("https://accounts.google.com","username"
,"password",session.driver)
Google.UserLogin()
Which creates a browser session using the following code:
class session():
def __init__(self,driver,options):
self.__name = "BrowserSession"
self.driver = driver
self.options = options
def launch(self):
driver = self.driver(options=self.options)
return driver
Which then uses the session to attempt a login:
class site():
def __init__(self,url,username,password):
self.url=url
self.username=username
self.password=password
class GoogleLogin(site):
def __init__(self,url,username,password,session):
site.__init__(self,url,username,password)
self.session = session
def UserLogin(self):
now = self.session.get(self.url) #go to site
#perform the login
Can anyone see what I am doing wrong?
Upvotes: 1
Views: 2569
Reputation: 1885
You need to save the initialised driver returned from session.launch()
and pass that to GoogleLogin
instead of session.driver
which is the still uninitialised driver:
driver = session.launch()
Google = GoogleLogin("https://accounts.google.com", "username", "password", driver)
Upvotes: 1