Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.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/8/selenium/4.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 Selenium-在网页上查找动态单词_Python_Selenium_Web - Fatal编程技术网

Python Selenium-在网页上查找动态单词

Python Selenium-在网页上查找动态单词,python,selenium,web,Python,Selenium,Web,我试图通过在Python上使用Selenium来检查网页上是否有单词。 问题是这个词是动态的:它只有在我做了一些动作后才会出现(在我的例子中,是在下拉列表中选择一个选项) 我试着用 "text" is in driver.page_source" 但它不起作用:它不会检测到我的动态文本(即使它检测到其他静态文本) 我不知道它为什么不起作用。请检查在执行操作后是否获得页面源代码,这些操作将使文本出现:`do_some_actions()“text”位于driver.page_source`。如果

我试图通过在Python上使用Selenium来检查网页上是否有单词。 问题是这个词是动态的:它只有在我做了一些动作后才会出现(在我的例子中,是在下拉列表中选择一个选项)

我试着用

"text" is in driver.page_source"
但它不起作用:它不会检测到我的动态文本(即使它检测到其他静态文本)


我不知道它为什么不起作用。

请检查在执行操作后是否获得页面源代码,这些操作将使文本出现:`do_some_actions()“text”位于driver.page_source`。如果你确信你做的一切都是正确的,请提供一个例子(或链接),通常文本的出现或消失是由网页元素控制的。尝试使用隐式(
driver.implicit\u wait
)或显式(
WebDriverWait
)wait轮询元素。见@NChechulin@Fearlessniper谢谢你的帮助。这实际上就是我的代码的样子:
driver.get('http//example.com')
driver.implicly\u wait(10)
代码驱动程序。如果“text”在驱动程序中,则implicly\u wait(10)
打印('Exist')
其他:
打印('notexist Exist'))
包含文本的标签是什么?@Rob您可以尝试模仿用户的行为,比如选择下拉菜单,然后尝试检索文本吗?有时在页面上,javascripts会从页面中删除元素,而不是将其设置为不可见。