如何在使用 cucumber-capybara(selenium -chromeDriver) 测试时允许弹出相机权限

发布于 2025-01-14 15:51:42 字数 1017 浏览 2 评论 0原文

我有链接将打开一个新页面来执行某些任务。只有在允许相机权限后我才能进一步进行。

弹出窗口

检查此处 - 提示 - 相机权限

首先会出现一个确认弹出窗口,询问相机权限。单击“允许”按钮后,会出现浏览器权限弹出窗口。 它与我们访问任何网站时出现的所有弹出窗口类似

检查此处 - 浏览器权限弹出窗口

我有一个用 Gherkin 语法编写的功能文件和一个使用水豚语法编写的步骤定义文件。

步骤定义

Then('I click test link') do
  test_window = window_opened_by do
    find(:css, "a[href='example.com/test']").click()
    # sleep(5)
  end
  within_window test_window do
      click_button 'Allow'
  end
  sleep(10)
end

单击“允许”按钮后,会出现浏览器权限弹出窗口。请检查附件图像。 我需要获得该许可。有人可以建议如何使用 capybara-cucumber 和 selenium chromeDriver 来做到这一点。

如果你知道我如何在 cypress 中做同样的事情,请提出建议。赛普拉斯不允许摄像头许可。我已经使用过 npm 模块,但它对我不起作用。 还有其他替代方法可以做同样的事情吗?

I have link that will open a new page to do some task. I can only proceed further only after allowing camera permissions.

popup window

check here - Prompt- camera permission

First a confirmation popup appears which ask for camera permissions. After clicking on allow button browser permission popup appears.
it's similar to all pops that appears when we visit any website

check here - Browser permission popup

I have a feature file written in Gherkin syntax and a step definition file written using capybara syntax.

step definition

Then('I click test link') do
  test_window = window_opened_by do
    find(:css, "a[href='example.com/test']").click()
    # sleep(5)
  end
  within_window test_window do
      click_button 'Allow'
  end
  sleep(10)
end

After clicking allow button browser permission pop appears.Please check the attached images.
I need to allow that permission. can someone suggest how to do that using capybara-cucumber with selenium chromeDriver.

If you have any idea how i can do the same thing in cypress please suggest. Cypress is not allowing camera permission. I have already used a npm module but it didn't worked for me.
Any other alternative to do the same ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪少女 2025-01-21 15:51:42

您是否尝试添加 --use-fake-ui-for-media-stream--use-fake-device-for-media-stream 参数设置所需的功能?

have you tried to add the --use-fake-ui-for-media-stream or --use-fake-device-for-media-stream argument when you set the desired capabilities?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文