Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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 使用xpath时隐藏的元素是可见的_Python_Angularjs_Xpath_Webdriver - Fatal编程技术网

Python 使用xpath时隐藏的元素是可见的

Python 使用xpath时隐藏的元素是可见的,python,angularjs,xpath,webdriver,Python,Angularjs,Xpath,Webdriver,我有一个angular中的wirten应用程序,我创建的所有xpath都可以在DOM中看到,但不能在页面上看到。所以,若我想检查元素在执行某个操作后是否可见,我不能这样做,因为webdriver即使在测试失败时也可以看到它 f、 e。 我想测试登录表单,登录后我想看看是否有可见的元素。当我放入无效数据时,测试应该失败,但仍然可以找到这个元素,即使他是隐藏的 我希望selenium只查找可见元素,如何才能做到这一点?您可以按照xpath只提供可见元素的方式构建xpath。以下是google.com

我有一个angular中的wirten应用程序,我创建的所有xpath都可以在DOM中看到,但不能在页面上看到。所以,若我想检查元素在执行某个操作后是否可见,我不能这样做,因为webdriver即使在测试失败时也可以看到它

f、 e。 我想测试登录表单,登录后我想看看是否有可见的元素。当我放入无效数据时,测试应该失败,但仍然可以找到这个元素,即使他是隐藏的


我希望selenium只查找可见元素,如何才能做到这一点?

您可以按照xpath只提供可见元素的方式构建xpath。以下是google.com

//input[@name='btnK' and not(ancestor::div[contains(@style,'display:none')]) and not(ancestor::div[contains(@style,'display: none')])]

尝试使用
is\u display()
方法。谢谢,效果很好!