繁体   English   中英

无法在 Selenium 中找到元素?

[英]Unable to locate element in Selenium?

我在 Pycharm 中收到以下错误:

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"css selector","selector":".fbc-imageselect-checkbox-9"}

它在此行上产生此错误:

driver.find_element_by_css_selector('.fbc-imageselect-checkbox-9').click()

其中driver是 firefox,使用 selenium。 我试图点击链接到网站上的 CSS 选择器fbc-imageselect-checkbox-9的项目: http : fbc-imageselect-checkbox-9

请注意,将您的用户代理更改为移动设备将生成图像网格。

我究竟做错了什么? 这个 CSS 选择器不应该工作吗?

它应该工作吗? 可能不是。 当我查看页面时,没有这样的元素(UA "Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"):

jQuery.find(".fbc-imageselect-checkbox-9")
Array [  ]

您可能需要更健壮地重写您的查询。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM