SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.63k stars 8.18k forks source link

[🐛 Bug]: Is this selenium issue or code issue? #12797

Closed ghost closed 1 year ago

ghost commented 1 year ago

What happened?

image

Can't fetch element.

How can we reproduce the issue?

iframe_element = find_captcha_iframe(self.driver)
print("The iframe with captcha did not appear")
from ptpython.repl import embed
embed(globals(), locals())
def find_captcha_iframe(driver):
    try:
        # Find all <div> elements with class "captchaContainer-*" where * is a random string
        div_elements = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, '//div[contains(@class, "captchaContainer-")]')))
        for div_element in div_elements:
            # Check if the class attribute contains "captchaContainer-" followed by a random string
            class_attribute = div_element.get_attribute('class')
            if class_attribute and "captchaContainer-" in class_attribute:
                # Attempt to find a child <div> and an <iframe> within the parent <div>
                child_div = div_element.find_element(By.XPATH, './div')
                iframe = child_div.find_element(By.TAG_NAME, 'iframe')
                if child_div and iframe:
                    return iframe
    except Exception as e:
        print("An error occurred:", e)
        from ptpython.repl import embed
        embed(globals(), locals())
    return None

I am using manually to fetch highest level div and go downwards but even highest level div fetching can't be done. image Basically fetching element with aria-label="CAPTCHA" also fails. And that is div for entire captcha box image

Relevant log output

Its reproducible easily via discord website.

Operating System

Linux Debian

Selenium version

selenium selenium==4.11.2

What are the browser(s) and version(s) where you see this issue?

Chromium 117

What are the browser driver(s) and version(s) where you see this issue?

Chromedriver 117

Are you using Selenium Grid?

Not sure

github-actions[bot] commented 1 year ago

@neomachiney, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] commented 11 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.