You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python Selenium使用select方法时出现'module' object is not callable错误

问题解决

错误原因

  1. 你误将Selenium的Select类所在的模块当作可调用对象使用——select是模块名,不是可实例化的类,正确的类是selenium.webdriver.support.ui下的Select。
  2. 代码存在拼写错误:selectByVisbleText应为select_by_visible_text(Python版本的Selenium方法采用蛇形命名,且单词"Visible"拼写错误)

修正后的代码

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select  # 导入正确的Select类

dob = 12

driver = webdriver.Chrome()
driver.get("https://www.avant.com/apply")
driver.implicitly_wait(10)
# 实例化Select类,注意首字母大写
month = Select(driver.find_element(By.ID, 'person_date_of_birth_month'))

if dob == 12:
    # 使用正确的方法名
    month.select_by_visible_text('Jan')

内容的提问来源于stack exchange,提问作者thrvxx

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 10:52:06