Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to switch to another iframe by XPATH, and click a button or something like that? #214

Open
louissiu198 opened this issue May 7, 2024 · 3 comments

Comments

@louissiu198
Copy link

No description provided.

@test4cz
Copy link

test4cz commented May 7, 2024

<iframe>元素是一种特殊的元素,它既是元素,也是页面,因此独立一个章节对其进行介绍。

与 selenium 不同,DrissionPage 无需切入切出即可处理<iframe> 元素。因此可实现跨级元素查找、元素内部单独跳转、同时操作<iframe>内外元素、多线程控制多个<iframe>等操作,功能更灵活,逻辑更清晰。

@test4cz
Copy link

test4cz commented May 7, 2024

@louissiu198
Copy link
Author

I tried that, WebDriverWait(driver, 15).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, '//[@id="hcaptchaContainer"]/iframe')))
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//
[@id="checkbox"]'))).click()
I need to target the Iframe in order to click the button. Drissionpage does not accept iframe console js. You can only run some specific js on the iframe console not the whole-page console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants