- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我安装了 geckodriver,因为 selenium 不再与最新版本的 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
到:
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/sspsHalkoylamasiYeni.jsf
最佳答案
您需要 .find_elements_by_tag_name()
...复数形式(注意“elements”中的“s”)。您使用的单数版本将只返回一个元素并且没有长度 (len
)。
关于python - Geckodriver 错误 : "FirefoxWebElement has no len()",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43712014/
我正在尝试从使用 xpath 找到的表中获取一些数据。代码和输出如下(如下),我从各种来源的零碎中获得了此代码。我希望能够将值“16.06”打印为字符串而不是“[u'16.06']”我尝试对“elem
我安装了 geckodriver,因为 selenium 不再与最新版本的 Firefox 兼容。请注意,我在 Mac 上使用 Spyder。之前,我成功地从一个网站上抓取了数据,但是一旦我切换到 g
这个问题在这里已经有了答案: TypeError: 'WebElement' object is not iterable error (2 个答案) 关闭 4 年前。 我想通过 Python、se
我尝试过提取网页元素它经常给出这个错误: from selenium import webdriver driver=webdriver.Firefox() singer_name='Avenged
我是一名优秀的程序员,十分优秀!