chromedriver 版本: 125.0.6422.141 (r1287751)(64 位) chrome 版本:125.0.6422.142(官方版本)(64 位) 硒版本:4.21.0
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
options = webdriver.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
options.platform_name = 'Windows 10'
service = ChromeService(executable_path=r'C:\Users\rr\Desktop\TL\chromedriver.exe')
browser = webdriver.Chrome(options=options)
browser.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Android; Android 4.4.1; LG-F500L Build/KOT49H) AppleWebKit/601.44 (KHTML, like Gecko) Chrome/54.0.3656.325 Mobile Safari/602.8'})
browser.set_window_size(393, 851)
url = "https://www.google.com/"
browser.get(url)
当我删除 options.platform_name = 'Windows 10' 时,一切正常,但当我尝试添加平台名称时,出现此错误
`消息=消息:会话未创建:未找到匹配的功能
堆栈跟踪:
GetHandleVerifier [0x00007FF612EC1F52+60322]
(No symbol) [0x00007FF612E3CEC9]
(No symbol) [0x00007FF612CF7EBA]
(No symbol) [0x00007FF612D7632C]
(No symbol) [0x00007FF612D75451]
(No symbol) [0x00007FF612D770BC]
(No symbol) [0x00007FF612D76F90]
(No symbol) [0x00007FF612D6BFC3]
(No symbol) [0x00007FF612D39617]
(No symbol) [0x00007FF612D3A211]
GetHandleVerifier [0x00007FF6131D94AD+3301629]
GetHandleVerifier [0x00007FF6132236D3+3605283]
GetHandleVerifier [0x00007FF613219450+3563680]
GetHandleVerifier [0x00007FF612F74326+790390]
(No symbol) [0x00007FF612E4750F]
(No symbol) [0x00007FF612E43404]
(No symbol) [0x00007FF612E43592]
(No symbol) [0x00007FF612E32F9F]
BaseThreadInitThunk [0x00007FFDB1417344+20]
RtlUserThreadStart [0x00007FFDB30E26B1+33]`
尝试删除 options.platform_name 并且它运行没有问题,但是当我添加该行时,我收到错误
我能找到的唯一参考
.platform_name
是针对 Ruby 的,请参阅here,但没有描述它的作用或如何使用它。
.platformName
。有说明
这标识了远程端的操作系统,获取 platformName 将返回操作系统名称。
在基于云的提供商中,设置设置远程端的操作系统。platformName
但没有代码示例。