使用此代码
from selenium import webdriver
driver = webdriver.Firefox
driver.get("WebDriver","https://www.youtube.com")
它给了我这个错误:
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'
那是为什么,我该如何解决?
答案 0 :(得分:0)
get(url)
方法接受字符串形式的url,并定义为:
def get(self, url):
"""
Loads a web page in the current browser session.
"""
self.execute(Command.GET, {'url': url})
您只需要按如下所示以字符串形式传递url:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.youtube.com")