我已经导航到(https://gmet.edupage.org/)网页,登录并进入了完成我的代码的最后一步,即单击第二天箭头,该箭头在日历的各个日期之间循环。在程序仍然返回错误selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"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()
关于此功能为何不起作用的任何想法?
答案 0 :(得分:0)
这应该有效:
next_page_button = driver.find_element_by_xpath("//span[@class='next fa fa-angle-right']")
next_page_button.click()
答案 1 :(得分:0)
问题很简单,我只需要添加一个time.sleep命令,以便页面有时间加载。