【问题标题】:Save firefox profile generated by Selenuim Web Driver保存 Selenium Webdriver 生成的 firefox 配置文件
【发布时间】:2012-10-23 14:43:35
【问题描述】:

我使用 Selenium WebDriver 和 Firefox。每次 selenium 在 temp 文件夹中为 firefox 生成新的 anoniumus 配置文件并在退出后将其删除。我需要这个配置文件。我怎么才能得到它? F.e.配置文件存储在

C:\Documents and Settings\Developer\Local Settings\Temp\anonymous5583304190515426768webdriver-profile

关闭 WebDriver 后

driver.quit();

profile 将被删除,但它已被记录,我想在下一次迭代中使用它,方法是用它初始化 WebDriver:

FirefoxDriver driver = new FirefoxDriver(new FirefoxProfile(profileFolder));

是否可以保存配置文件而无需像在驱动程序工作时处理整个文件夹这样的肮脏黑客行为(我不确定它是否有效,因为在 Windows 中,文件夹在 firefox 启动时被锁定)? Selenium 中是否存在一些 API?

【问题讨论】:

    标签: java selenium webdriver selenium-webdriver


    【解决方案1】:

    你为什么不改变方法?

    • Create firefox profile 这将是干净的并以某种方式命名它,您知道它是什么。例如SELENIUM
    • 初始化Webdriver时:

       ProfilesIni allProfiles = new ProfilesIni();
       FirefoxProfile desiredProfile = allProfiles.getProfile("SELENIUM");
       WebDriver driver = new FirefoxDriver(desiredProfile);
      

    这样,您就可以确保在您进行测试的任何时候都会使用此配置文件...

    【讨论】:

    • 不幸的是,selenium 将数据从输入配置文件复制到时态配置文件中,例如匿名 5583304190515426768webdriver-profile,因此所有 cookie 都将在其中(并在测试关闭后被删除)。
    • @rdo 您只需查找 profile.path value 即可找回该 tmp 配置文件。 python绑定示例stackoverflow.com/a/33350778/2480481
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 1970-01-01
    • 2012-09-27
    • 2015-10-01
    • 2020-10-24
    相关资源
    最近更新 更多