首页 > 解决方案 > 在 Robot Framework 中创建 Firefox 配置文件

问题描述

需要创建一个 Firefox 配置文件运行时并为 Robot Open Browser 关键字提供配置文件路径

当前代码能够创建 Firefox 配置文件对象,但无法提取 Firefox 配置文件路径

Create Firefox Profile
    [Arguments]  ${DOWNLOADS_DIRECTORY}
    ${firefox_profile}=    Evaluate    sys.modules['selenium.webdriver'].FirefoxProfile()    sys, selenium.webdriver
    ${mime_types}=    Convert To String    application/octet-stream;application/vnd.ms-excel;text/plain;application/xml;text/comma-separated-values
    Call Method    ${firefox_profile}   set_preference    browser.download.folderList    1
    Call Method    ${firefox_profile}   set_preference    browser.download.manager.showWhenStarting    False
    Call Method    ${firefox_profile}   set_preference    browser.download.dir    ${DOWNLOADS_DIRECTORY}
    Call Method    ${firefox_profile}   set_preference    browser.helperApps.neverAsk.saveToDisk    ${mime_types}
    Call Method    ${firefox_profile}   update_preferences
    [Return]    ${firefox_profile}.path

标签: pythonseleniumselenium-webdriverrobotframework

解决方案


推荐阅读