0

using this code

from selenium import webdriver
driver = webdriver.Firefox
driver.get("WebDriver","https://www.youtube.com")

It gives me this error:

Traceback (most recent call last):
  File "C:/Users/Zohaib/PycharmProjects/FirstPyTesting/youtube.py", line 3, in <module>
    driver.get("WebDriver","http://localhost:81/")
  File "C:\Users\Zohaib\PycharmProjects\FirstPyTesting\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
    self.execute(Command.GET, {'url': url})
AttributeError: 'str' object has no attribute 'execute'

Why is that and how can I fix it?

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

1

get()

The get(url) method accepts an url in the form of a string and is defined as:

def get(self, url):
    """
    Loads a web page in the current browser session.
    """
    self.execute(Command.GET, {'url': url})

Solution

You you need to pass only the url in the form of a string as follows:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.youtube.com")   
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352