python - WebDriver'对象没有属性 'find_element_by_id'

标签 python google-chrome selenium-chromedriver webdriver

我正在运行 tiktok scrapper,但收到此错误。我该如何修复它?

C:\Users\edit\Downloads\Compressed\shot\shorts\tiktokscraper\downloader.py:31: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(executable_path=driver_path, options=option)

DevTools listening on ws://127.0.0.1:50049/devtools/browser/85f1588d-2d26-4cbf-bd8d-a992dc20e370
[8724:8648:0711/140535.825:ERROR:device_event_log_impl.cc(214)] [14:05:35.836] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter
failed.
Traceback (most recent call last):
  File "C:\Users\edit\Downloads\Compressed\shot\shorts\tiktokscraper\downloader.py", line 98, in <module>
    download(tiktok_list)
  File "C:\Users\edit\Downloads\Compressed\shot\shorts\tiktokscraper\downloader.py", line 47, in download
    url_field = driver.find_element_by_id('url')
AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

最佳答案

Selenium 版本 4.3.0 不再支持使用 driver.find_element_by_*。您应该使用 driver.find_element(By.ID, url) 来代替。

关于python - WebDriver'对象没有属性 'find_element_by_id',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72939940/

相关文章:

python - selenium 未启用 chrome 69 上的 Flash

python - 非阻塞文件结束

python - 在 Python 中从数据点中查找移动平均值

html - 使用 chrome 检查响应式设计

python - WebDriverException : Service U:/Scraping/chromedriver. exe 意外退出。状态代码为:1,同时使用 Chrome 和 Python

javascript - 这是 Chrome 错误还是我对 "use strict"和 eval 的使用无效?

java - 如何修复未知错误: unhandled inspector error: "Cannot find context with specified id"

python - 在Python中读取和写入大型CSV文件

javascript - 是否可以使用 javascript 从 django 模型数据库中获取数据?

selenium-chromedriver - 如何使用 Google Chromium GN 构建目标?