hallopeterswelt
hallopeterswelt

Reputation: 53

Change to iframe

On gmx.net I want to click on a hyperlink in an email.

But the hyperlink is enclosed with two iframes.

How do I change into it?

My approach:

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"]')))

enter image description here

enter image description here

Upvotes: 0

Views: 101

Answers (1)

hfontanez
hfontanez

Reputation: 6168

As I suspected, your XPath is incorrect.

You have to either use

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']')))

or

WebDriverWait(driver, 10).until(expected_conditions.frame_to_be_available_and_switch_to_it((By.XPATH, '//iframe[contains(@class, 'app-stack_children--active']')))

Obviously, the first option is better than the second one. There's always a chance that contains() will match more than one element. It is less probable if using equality.

Upvotes: 1

Related Questions