【问题标题】:Execute headless chrome browser in Linux machine using Robot framework使用 Robot 框架在 Linux 机器上执行 headless chrome 浏览器
【发布时间】:2021-07-27 12:03:30
【问题描述】:

我在 Linux 机器上可用的 Jenkins 管道中执行我的脚本。我正在尝试使用 Chrome 选项,并且仅添加了适用于 Linux 的 chrome 驱动程序。我收到以下错误。

WebDriverException:消息:未知错误:找不到 Chrome 二进制文件

请找到以下代码供您参考。

${result} =    Replace String    ${EXECDIR}     //       \\
log     ${result}

${chrome_path}      Catenate   SEPARATOR=      ${result}        /      Linux    /   chromedriver
log     ${chrome_path}
${options}  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
#Call Method  ${options}  add_argument  --headless
Call Method  ${options}  add_argument  --disable-gpu
Call Method  ${options}  add_argument  args: ['--disable-setuid-sandbox', '--no-sandbox']

${preferences} =    Create Dictionary   setAcceptUntrustedCertificates=True    setAssumeUntrustedCertificateIssuer=True
Create WebDriver  Chrome   chrome_options=${options}   desired_capabilities=${preferences}      executable_path=${chrome_path}
Set Window Size     ${1400}     ${600}
Maximize Browser Window
sleep    3s
Go to     ${URL}

【问题讨论】:

  • 由于您正在发送二进制文件的路径,我想说您已经在尝试修复某些问题并且遇到了 Jenkins 用户无法访问 chrome 二进制文件的权限问题。我将首先使用 Jenkins 用户登录并检查 chrome 二进制文件是否在路径变量上

标签: linux selenium jenkins robotframework


【解决方案1】:

错误是找不到 chrome 二进制文件(chrome,而不是 chromedriver)。您可以通过设置binary_location 选项来解决此问题:

${options.binary_location}=  Set variable  /the/path/to/chrome

【讨论】:

    猜你喜欢
    • 2018-06-08
    • 2015-02-27
    • 2020-06-04
    • 2019-02-23
    • 2020-08-30
    • 2018-02-16
    • 2021-03-19
    • 2019-02-02
    • 1970-01-01
    相关资源
    最近更新 更多