首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Selenium webdriver 'command_executor‘错误

Selenium webdriver 'command_executor‘错误
EN

Stack Overflow用户
提问于 2022-05-04 02:55:39
回答 1查看 419关注 0票数 1

大家好。这个小剧本快把我逼疯了,所以我叫后援。当我运行下面的脚本时,它给了我

TypeError:init()获得参数'command_executor‘的多个值

如果有人能帮我一把,那就太好了。

代码语言:javascript
运行
复制
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

# The main process calls this function to create the driver instance.
def createDriverInstance():
    options = Options()
    options.add_argument('--disable-infobars')
    driver = webdriver.Chrome(r'mypath',chrome_options=options)
    return driver

# Called by the second process only.
def secondProcess(executor_url, session_id):
    options = Options()
    options.add_argument("--disable-infobars")
    options.add_argument("--enable-file-cookies")
    capabilities = options.to_capabilities()
    same_driver = webdriver.Remote(r'mypath',command_executor=executor_url,desired_capabilities=capabilities)
    same_driver.close()
    same_driver.session_id = session_id
    same_driver.get("https://www.wikipedia.org")
    time.sleep(4)
    same_driver.quit()

if __name__ == '__main__':
    driver = createDriverInstance()
    driver.get("https://google.com")
    time.sleep(2)

    # Pass the driver session and command_executor to the second process.
    secondProcess(driver.command_executor._url,driver.session_id)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-04 21:59:41

webdriver.Remote 不会为chromedriver文件的路径设置了一个参数,因此您不必使用它。

因此,只需将这一行改为:

代码语言:javascript
运行
复制
same_driver = webdriver.Remote(r'mypath',command_executor=executor_url,desired_capabilities=capabilities)

对此:

代码语言:javascript
运行
复制
same_driver = webdriver.Remote(command_executor=executor_url,desired_capabilities=capabilities)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72107484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档