【问题标题】:Firefox profile not loaded in Open Browser with Robot Framework SeleniumLibrary 4.0Firefox 配置文件未在使用 Robot Framework SeleniumLibrary 4.0 的打开浏览器中加载
【发布时间】:2020-02-14 05:51:49
【问题描述】:

我为 Firefox 创建了一个新的配置文件,以与 Robot Framework SeleniumLibrary 一起使用。但是配置文件没有使用以下加载

*** Settings ***
Library    SeleniumLibrary

*** Keywords ***
Just testing
    Open Browser    about:blank    Firefox    ff_profile_dir=C:${/}Users${/}Administrator${/}AppData${/}Roaming${/}Mozilla${/}Firefox${/}Profiles${/}dev

*** Test Cases ***
Just testing

使用哪个配置文件可以从页面about:profiles看到

但是,在 webdriver 启动的浏览器上检查 about:profiles 时,该配置文件未标记为正在使用:page about:profiles on a browser launched by Webdriver

任何想法为什么没有加载 Firefox 配置文件? 编辑:我如何确定配置文件是否已加载?

看geckodriver日志目录好像完全不一样

mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\rust_mozprofile2iM6KC"

我创建单独配置文件的原因是在启动自动化测试套件时使用 AutoAuth 扩展绕过 NTLM 身份验证。

硒库 4.0.0 机器人框架 3.1.2(win32 上的 Python 3.7.4) 火狐 69.0.3

【问题讨论】:

    标签: firefox selenium-webdriver robotframework firefox-profile


    【解决方案1】:

    我查看了我的自定义关键字来设置 firefox 配置文件:

    from robot.api import logger
    from selenium.webdriver import FirefoxProfile
    
    class SeleniumPyExtension:
    
        @staticmethod
        def setup_firefox_profile(download_dir):
            profile = FirefoxProfile()
            logger.info('Download dir is {}'.format(download_dir))
            profile.set_preference("browser.download.dir", download_dir)
            profile.set_preference("browser.download.folderList", 2)
            profile.set_preference(
                'browser.helperApps.neverAsk.saveToDisk',
                'image/jpeg;'\
                'application/vnd.ms-excel;'\
                'application/octet-stream;'\
                'application/pdf;'\
                'application/ogg;'\
                'audio/mpeg;'
            )
            profile.set_preference("pdfjs.disabled", True)
            profile.update_preferences()
            profile_dir = profile.profile_dir
            logger.info('Profile is located at {}'.format(profile_dir))
            return profile_dir
    

    并检查了它创建的内容,发现它创建的目录只有user.js 和一堆user_pref(...),如here 所述。

    【讨论】:

      猜你喜欢
      • 2021-08-28
      • 2021-04-22
      • 2017-11-18
      • 1970-01-01
      • 2018-06-16
      • 2017-09-01
      • 2019-09-01
      • 2020-10-20
      • 2013-04-09
      相关资源
      最近更新 更多