selenium python错误“dict”对象没有“click”属性

2024-10-01 00:19:59 发布

您现在位置:Python中文网/ 问答频道 /正文

if href.startswith("https://store.steampowered"):
    browser.get(href)

    if browser.current_url.startswith("https://store.steampowered.com/agecheck"):
        area = browser.find_element_by_id("agecheck_form")
        location_field = area.find_element_by_id("ageYear")

        for option in location_field.find_elements_by_tag_name("option"):
            if int(option.text) == 1999:
                option.click()
                break

            enter = browser.find_element_by_xpath('//*[@id="agecheck_form"]/a')
            enter.location_once_scrolled_into_view.click()

我对这段代码的意图是去一个steam游戏页面来获取游戏的价格。如果它遇到年龄检查墙,它会运行我上面的代码。在

https://store.steampowered.com/agecheck/app/489830/

我的问题是无论我如何格式化enter按钮上的click事件,它都会给我错误:“dict”对象没有属性“click”

我已经查过字典是什么,但还是找不到答案。 我怀疑这个问题可能与我的选项循环有关。在


Tags: storehttpsbrowseridbyiflocationelement