壁虎驱动程序错误:"FirefoxWebElement has no len()"



我安装了geckodriver,因为硒不再与最近版本的firefox兼容。请注意,我正在Mac上使用Spyder。以前,我已经成功地从网站上刮了数据,但是一旦我改用geckodriver,我就必须对脚本进行修改。例如,

 browser.find_by_id('closeMessageButton').click() 

现在

 browser.find_element_by_id('closeMessageButton').click() 

我修改了以下内容:

prov_count = len(browser.find_by_id("j_id48:j_id49:j_id108:cmbSecimCevresi").first.find_by_tag('option'))-1

to:

prov_count = len(browser.find_element_by_id("j_id48:j_id49:j_id108:cmbSecimCevresi").find_element_by_tag_name('option'))-1

但我会收到以下错误:" TypeError:类型'FirefoxWebelement'的对象没有Len((

我正在尝试在下面的网站上获取列表的计数,因此我可以在"*il adi"下循环浏览列表:https://sonuc.ysk.gov.tr/module/sspshalkallamasiyeni.jsf <</p>

您想要 .find_elements_by_tag_name() ...复数版本(请注意"元素"中的" s"(。您使用的单数版本只会返回一个元素,并且没有长度(len(。

相关内容

最新更新