'Selenium - Unable to find input elements inside iframe using SwitchTo()

I have a hard time locating two input elements of a specific website.

website

Well, as you can see above, "username" input element and "password" input element are inside an iframe with id = tab1.

So I tried (among other things) something like this:

driver = webdriver.Firefox()

driver.get('https://www.website.com/sites/en/Pages/default.aspx')

driver.SwitchTo().Frame(driver.FindElement(By.id("tab1")));

username = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="login-form"]/div[1]/input')))
username.send_keys(credentials.username)

password = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="login-form"]/div[2]/input')))
password.send_keys(credentials.password)

submit = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="loginBtn"]')))

action = ActionChains(driver)
action.move_to_element(submit).click().perform()

That is, I switched to frame "tab1" and then searched for the elements with their XPath. (Both full XPath and simple XPath).

But I get the following error again and again:

Process finished with exit code -1073740791 (0xC0000409)

without even activating "try-except" to show me something I can use for debugging.

Well, the question is: can I locate these elements somehow?

Thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source