【问题标题】:How to handle pop up Browser in Robot Framework?如何处理 Robot Framework 中的弹出式浏览器?
【发布时间】:2019-08-29 20:31:28
【问题描述】:

我需要处理弹出浏览器以允许使用 Robot Framework 的相机。 赞这个https://i.stack.imgur.com/jcWnL.png

我正在尝试使用键盘命令,我可以使用 TAB 去允许按钮,但是当我发送 Keys Press None ENTER 时,没有在所选按钮(允许按钮)中按 Enter,而是在 Firefox 中使用 tab 命令我可以' t 访问允许按钮。 这个方案我已经试过了但是不行,不要让摄像头How to access microphone(camera) in robot framework?

有人知道如何解决这个问题吗?我需要一个适用于 Chrome 和 Firefox 的解决方案

【问题讨论】:

    标签: selenium robotframework


    【解决方案1】:

    您可以将 Selenium 与 C#、Python、Java 或 JS 一起使用。此选项也可以与 Firefox 和 chrome 一起使用。首先,您必须将配置传递给配置文件,因此一旦您进入需要相机权限的页面,它将自动授予它们。下面是一个简单的python示例:)

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    opt = Options()
    opt.add_argument("--disable-infobars")
    opt.add_argument("start-maximized")
    opt.add_argument("--disable-extensions")
    
    # 1 = Allow, 2 = Block
    opt.add_experimental_option("prefs", { \
        "profile.default_content_setting_values.media_stream_mic": 1, 
        "profile.default_content_setting_values.media_stream_camera": 1,
      })
    
    driver = webdriver.Chrome(chrome_options=opt)
    driver.get('http://somesite.com)
    

    这里有一个教程可以帮助您立即启动和运行https://help.crossbrowsertesting.com/selenium-testing/getting-started/python/

    【讨论】:

    • 感谢您的回答@David-silveiro 但我如何在机器人框架中使用它?我试过这种方法但没有用:*** Variables *** ${SiteOptionscam} Create Dictionary profile.default_content_setting_values.media_stream_camera": 1 ${desired caps} = Create Dictionary chromeOptions=${SiteOptionscam} *** Test Cases *** Test01 Open Browser ${url} Chrome desired_capabilities=${desired caps} Login action Click on the button that shows the pop up不允许摄像头
    • 如果您不想使用 Chrome 驱动程序,我认为这可能会有所帮助 :) stackoverflow.com/questions/43389550/…
    • 非常感谢,我之前已经试过了但是不行,一定是我做错了,不过这次成功了,谢谢:)
    • 你知道我在 Firefox 中是怎么做的吗?
    • 我真的没有太多机会使用 Robot 框架,所以我真的帮不上忙,但如果有 chrome,你可能也幸运地使用了 Firefox!如果你觉得我的回答对你有帮助,当你有机会时,请随时标记它:)
    猜你喜欢
    • 2017-08-06
    • 2020-04-09
    • 1970-01-01
    • 1970-01-01
    • 2023-02-13
    • 1970-01-01
    • 2019-02-18
    • 2017-04-23
    • 2021-08-28
    相关资源
    最近更新 更多