在gmx.net上,我想点击电子邮件中的超链接。
但是超链接包含两个iframes。
我该怎么换呢?
我的方法:
WebDriverWait(driver, 10).until(expected_conditions.frame_to_be_available_and_switch_to_it((By.XPATH, '//iframe[@class="app-stack_children--active"]')))
WebDriverWait(driver, 10).until(expected_conditions.frame_to_be_available_and_switch_to_it((By.XPATH, '//iframe[@class="js-box-flex need-overlay"]')))


发布于 2022-02-02 18:56:03
正如我所怀疑的,你的XPath是不正确的。
你要么用
WebDriverWait(driver, 10).until(expected_conditions.frame_to_be_available_and_switch_to_it((By.XPATH, '//iframe[@class='app-stack__children l-vertical app-stack__children--active']')))或
WebDriverWait(driver, 10).until(expected_conditions.frame_to_be_available_and_switch_to_it((By.XPATH, '//iframe[contains(@class, 'app-stack_children--active']')))显然,第一种选择比第二种更好。contains()总是有可能匹配多个元素。如果使用平等,则不太可能。
https://stackoverflow.com/questions/70960169
复制相似问题