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
在使用selenium的python中,不能通过css_选择器单击按钮_Python_Selenium_Web Scraping - Fatal编程技术网

在使用selenium的python中,不能通过css_选择器单击按钮

在使用selenium的python中,不能通过css_选择器单击按钮,python,selenium,web-scraping,Python,Selenium,Web Scraping,我已经导航到一个()网页,登录并进入完成代码的最后一步,即单击一个第二天箭头,该箭头在日历的各个日子中循环。问题是,在程序返回错误之前,我已经多次这样做了。selenium.common.exceptions.NoSuchElementException:Message:没有这样的元素:无法定位元素:{“方法”:“css选择器”,“选择器”:“next.fa.fa angle right”} 我想知道,当源网页代码如下所示时,为什么它不能获取元素: <span class="ne

我已经导航到一个()网页,登录并进入完成代码的最后一步,即单击一个第二天箭头,该箭头在日历的各个日子中循环。问题是,在程序返回错误之前,我已经多次这样做了。
selenium.common.exceptions.NoSuchElementException:Message:没有这样的元素:无法定位元素:{“方法”:“css选择器”,“选择器”:“next.fa.fa angle right”}

我想知道,当源网页代码如下所示时,为什么它不能获取元素:

<span class="next fa fa-angle-right" data-smer="1" style="display:inline-block"></span>
next_page_button = driver.find_element_by_x('.next.fa.fa-angle-right')

next_page_button.click()
关于为什么这个方法不起作用,你有什么想法吗?

应该可以:

next_page_button = driver.find_element_by_xpath("//span[@class='next fa fa-angle-right']")

next_page_button.click()

问题很简单,我只需要添加一个time.sleep命令,这样页面就有时间加载。

您是否运行了curl命令来查看没有javascript的源代码?我猜元素只在加载javascript时存在。