Skip to content

AttributeError: 'NoneType' object has no attribute 'find_element' when using seleniumbase CDP mode #3554

@matteocacciola

Description

@matteocacciola

I am implementing the current script

from seleniumbase import SB


url = "https://journals.ametsoc.org/view/journals/aies/1/1/aies.1.issue-1.xml"

with SB(uc=True) as driver:
    driver.activate_cdp_mode(url)
    driver.cdp.maximize()

    driver.sleep(1)
    driver.uc_gui_click_captcha()

    try:
        tags = driver.cdp.find_all("div.ico-access-open", timeout=1)
    except Exception:
        tags = []

    try:
        tags += driver.cdp.find_all("div.ico-access-free", timeout=1)
    except Exception:
        pass

    for i, tag in enumerate(tags):
        grandparent = tag.get_parent().get_parent()
        print(i, type(grandparent))
        print(grandparent.find_element("a.c-Button--link"))

Unfortunately, that is the only way I have to grab the element of my interest. Here is the error I have at the prompt

0 <class 'seleniumbase.undetected.cdp_driver.element.Element'>
Traceback (most recent call last):
  File "/home/monster/dati/web/pischool-campus/data-pipeline/test.py", line 29, in <module>
    print(grandparent.find_element("a.c-Button--link"))
TypeError: 'NoneType' object is not callable

Therefore, despite grandparent is of type seleniumbase.undetected.cdp_driver.element.Element, then grandparent.find_element results in that weird error. Can anyone support me please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    UC Mode / CDP ModeUndetected Chromedriver Mode / CDP Modeinvalid usageYou may need to change what you're doing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions