DrissionPage icon indicating copy to clipboard operation
DrissionPage copied to clipboard

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

Open louissiu198 opened this issue 9 months ago • 3 comments

louissiu198 avatar May 07 '24 07:05 louissiu198

test4cz avatar May 07 '24 14:05 test4cz

https://www.drissionpage.cn/ChromiumPage/iframe/

test4cz avatar May 07 '24 14:05 test4cz

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

louissiu198 avatar May 08 '24 03:05 louissiu198

如果是异域iframe,先获取iframe元素,再使用这个元素在里面找button元素。如果是同域iframe,除了上面这种方法,还可以直接用定位符拿到里面的button元素进行操作。

g1879 avatar Jul 01 '24 02:07 g1879