Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何选择弹出消息;允许;这是HTML页面的Span元素。解决方案应使用按css选择器查找元素_Python_Html_Selenium_Ui Automation - Fatal编程技术网

Python 如何选择弹出消息;允许;这是HTML页面的Span元素。解决方案应使用按css选择器查找元素

Python 如何选择弹出消息;允许;这是HTML页面的Span元素。解决方案应使用按css选择器查找元素,python,html,selenium,ui-automation,Python,Html,Selenium,Ui Automation,我对Web UI自动化非常陌生,我的查询可能非常基本。 我的UI自动化要求,我必须单击“允许”弹出消息。你能不能帮我,我如何才能做到这一点将工作,我给了以下尝试,但不幸的是,这些尝试没有工作 以下事情无法奏效: driver.find_element_by_css_selector('p.instructions.ALLOW').click(); ## #driver.find_element_by_css_selector('p.instruction

我对Web UI自动化非常陌生,我的查询可能非常基本。
我的UI自动化要求,我必须单击“允许”弹出消息。你能不能帮我,我如何才能做到这一点将工作,我给了以下尝试,但不幸的是,这些尝试没有工作

以下事情无法奏效:

driver.find_element_by_css_selector('p.instructions.ALLOW').click();




        ##

        #driver.find_element_by_css_selector('p.instructions').click()
        document = 'ALLOW'
        #driver.find_element_by_xpath("//*[normalize-space()='"+document+"']").click();

        #driver.findElement_by_xpath("//span[contains(., \"" + document + "\")]").click();
        #driver.find_element_by_xpath("//p[contains(text(),'ALLOW')]/span").click(); ##2
        #driver.find_element_by_xpath("//span[contains(text(),'ALLOW')]").click(); ##2
        #driver.find_element_by_xpath("//span[contains(text(),'ALLOW')]").click()
        #driver.find_element_by_xpath("//span[contains(text(),'Allow')]").click() 
        #//a[contains(text(), 'Created By Me')]/span
        #section.hidden.MouseAllowCameraView
        #content = driver.find_element_by_css_selector('section.MouseAllowCameraView').click()
==========HTML代码===========

<section class="MouseAllowCameraView hidden"><div class="background"></div>
<div class="page">

    <div class="content">

        <p class="instructions"><bdo dir="ltr">Activate your webcam by clicking <span>**ALLOW**</span><br>at the top of your browser window.</bdo></p>

    </div>

    <div class="webcam-arrow"></div>

</div>
</section>

通过单击浏览器窗口顶部的**允许**
激活网络摄像头


===========================结束HTML代码查看网站后,您的问题和答案对我来说变得更加清晰。 只能在Google Chrome中打开,一旦我们点击开始按钮,就会弹出一个浏览器弹出窗口,要求用户点击“允许”继续

现在是实际问题

到目前为止,Selenium还不能自动控制浏览器(收藏夹栏、地址栏、菜单选项),我们点击“开始”按钮得到的窗口是chrome浏览器控件的一部分

要处理这种情况,您可以使用一些第三方工具,如SikuliAutoITROBOT

我建议您选择Sikuli,在这个帮助下,您可以单击允许按钮。 这里是完整的Sikuli和教程


如果有任何问题,请告诉我

感谢您为我的问题提供的解决方案。然而,我已经添加了您的代码,然后抛出了以下错误。。。“未处理的ElementNotVisibleException:“graphics\u WebGLHDMIChrome.justareflektorOpenCameraMouseMove失败:未处理的ElementNotVisibleException:消息:u'element不可见\n(会话信息:chrome=41.0.2265.0)\n(驱动程序信息:chromedriver=2.13(132ec988536bd3b30838fdc1ef8fe01454727cab),平台=Linux 3.10.18 x8664)“是的,此网站是公开的,其URL为。请检查上述修改后的答案。感谢鲁佩什的建议。此要求是使用Python的自动测试框架测试自动化的一部分。我不确定如何/是否可以使用‘Sikuli’来实现此类解决方案。您是否可以让我知道使用exi的其他解决方案?”sting python lib…我正在使用Ubuntu Linux OS…和Chromium OS…请使用链接以Sikuli开始。关于您的系统配置,是的,它是兼容的,事实上python是Sikuli的第一语言,您可以在Linux和Unix上使用它。从链接中,您可以下载Sikuli所需的所有文件。使用起来非常简单。只需保存在您的项目库中创建一个jar文件并开始使用它。