【发布时间】:2021-06-04 21:52:04
【问题描述】:
我的目标是使用 SeleniumLibrary(或 Selenium2Library)创建一个 Roboframework 脚本,为 Chrome 选择一个特定的配置文件路径(我需要重用配置文件)。
这是我正在使用的代码:
*** Settings ***
Library Selenium2Library
Library OperatingSystem
*** Test Cases ***
Test Profile
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${options.add_argument}= Set Variable --user-data-dir=/tmp/.org.chromium.Chromium.Test
Create WebDriver Chrome chrome_options=${options}
Go To chrome://version
Wait Until Page Contains JavaScript
Capture Page Screenshot
如果我运行脚本,我不会收到任何错误,但不幸的是,chrome 路径不受所需设置的影响(一直在创建 root+随机路径):
过去我已经使用 Python 代码和 Selenium Grid 成功实现了这一点:
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-notifications')
chrome_options.add_argument('--user-data-dir=/tmp/.com.google.Chrome.Test')
browser = webdriver.Remote(command_executor='http://192.168.99.100:4444/wd/hub',desired_capabilities = chrome_options.to_capabilities())
感谢任何帮助/评论。 非常感谢
【问题讨论】:
标签: selenium selenium-webdriver robotframework