通过Robot框架配置便携式浏览器二进制

问题描述 投票:0回答:3

我需要使用特定版本的便携式浏览器来运行我的机器人测试脚本,而不是主机上安装的那些。我怎样才能做到这一点? Selenium Capabilities有没有可用的选项?

我的要求是Chrome,IE和Firefox - 所有这些浏览器的便携版本。

selenium webdriver automated-tests robotframework portable-executable
3个回答
1
投票

在调用Create Webdriver关键字之前,您可以使用以下方法将二进制文件位置指定为实验选项。

Call Method ${chromeOptions}    add_experimental_option prefs   ${prefs}
${chromeOptions.binary_location}    Set Variable    <insert your path here>     
Create Webdriver    Chrome  chrome_options=${chromeOptions}

1
投票

可以这样做(与@ GPT14相同的答案,但更完整):

${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
${prefs}       Create Dictionary
Call Method    ${options}    add_experimental_option    prefs    ${prefs}
${options.binary_location}    Set Variable    ${setYourPathToChromePortableHere}
Create Webdriver    Chrome    chrome_options=${options}
Go To    ${URL}

0
投票

一种可能性是操纵PATH环境变量,以便它首先找到已安装的浏览器(在调用Create WebdriverOpen Browser之前)。

这可以使用OperatingSystem关键字来完成,例如Set Environment Variable

© www.soinside.com 2019 - 2024. All rights reserved.