当前位置:网站首页>Resolved (selenium operation Firefox Firefox browser error) attributeerror: 'webdriver' object has no attribute 'execute_ cdp_ cmd’
Resolved (selenium operation Firefox Firefox browser error) attributeerror: 'webdriver' object has no attribute 'execute_ cdp_ cmd’
2022-07-23 22:59:00 【No envy】
resolved (selenium Operate Firefox Firefox Browsers use stealth.min.js File hiding browser fingerprint feature error )AttributeError: ‘WebDriver’ object has no attribute ‘execute_cdp_cmd’
List of articles
Error code
My code is as follows , Want to use stealth.min.js File hide browser fingerprint features , I used to use Chrome There is no problem with the browser :
from selenium import webdriver
# 1. Initialize the configuration object
options = webdriver.FirefoxOptions()
# 2. No interface mode
options.add_argument('--headless')
options.add_argument('--disable-gpu')
# 3. Add request header to disguise browser
options.add_argument(
'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0')
# 4. Tell the browser to remove it webdriver trace
options.add_argument("--disable-blink-features=AutomationControlled")
# 5. Do not load pictures to improve access speed
options.add_argument('blink-settings=imagesEnabled=false')
options.add_argument('--disable-images')
driver = webdriver.Firefox(options=options)
# 6. An implicit wait 10 second
driver.implicitly_wait(10)
# 7. Hide browser fingerprint
with open('stealth.min.js') as f:
js = f.read()
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": js
})
driver.get('https://bot.sannysoft.com/')
driver.save_screenshot('1.png')
driver.quit()
Error message :
Traceback (most recent call last):
File "E:/Python Study /1.py", line 23, in <module>
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd'

Error report translation
Translation of error reporting content : Property error :“WebDriver” Object has no properties “execute\u cdp\u cmd”, And it can't be used without that method
Error reason
Error reason :cdp namely Chrome DevTools Protocal, Chrome Developer tools agreement , Only applicable to Chrome browser , Other browsers cannot be used , But I tried Edge You can also use a browser
resolvent
1. Remove the error code and do not hide the browser fingerprint
2. Switch to Chrome Google Chrome or Edge Browsers use stealth.min.js File hide browser fingerprint features
边栏推荐
- Multithreading problem: why should we not use multithreading to read and write the same socket connection?
- Tap series article 9 | application development accelerator
- Exch:pop3 and IMAP4 operation guide
- Tap series article 7 | easy to manage pipeline configuration
- (CVPR-2022)BiCnet
- [Matplotlib drawing]
- 20. Valid parentheses valid parentheses
- ES6箭頭函數的使用
- Crazy bull market, where to go in the second half? 2021-04-30
- Linked list - 203. remove linked list elements
猜你喜欢

H7-tool serial port offline burning operation instructions, support TTL serial port, RS232 and RS485 (2022-06-30)

What else do entrepreneurs need besides money? Exclusive interview with Mingyue Lake venture capital institutions

Matlab wavelet toolbox import signal error (doesn't contain one dimensional single)

系列文章|云原生时代下微服务架构进阶之路 - 微服务拆分的最佳实践

Linked list - 203. remove linked list elements

Investment suggestions for overseas senior players (2) 2021-05-03

After reading this article, thoroughly understand grpc!

1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
![[leetcode ladder] linked list · 203 remove linked list elements](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[leetcode ladder] linked list · 203 remove linked list elements

TAP 系列文章7 | 易于管理的流水线配置
随机推荐
ES6 other syntax and extended syntax summary
Finding all paths between two points in a directed graph
Inspiration from Buffett's shareholders' meeting 2021-05-06
Interface test
STM32F4查看系统各部分频率
1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
[leetcode ladder] linked list · 203 remove linked list elements
TAP 系列文章5 | 云原生构建服务
[C language] address book (static version)
Array -- 27. remove elements
软件测试工作内容太简单怎么办?
H7-tool serial port offline burning operation instructions, support TTL serial port, RS232 and RS485 (2022-06-30)
Multithreading problem: why should we not use multithreading to read and write the same socket connection?
The canfd/can interface offline burning operation instructions of h7-tool have been updated (2022-07-12)
狂神redis笔记10
Array -- 209. Subarray with the smallest length
[nuxt 3] (IX) server routing
小说里的编程 【连载之十九】元宇宙里月亮弯弯
The Minesweeper game
[laser principle and Application-8]: EMC design of laser circuit