Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

example site

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

driver = webdriver.Firefox()

driver.get('https://www.winbank.gr/sites/idiwtes/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.

>Solution :

wait=WebDriverWait(driver,10) 
wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"#tab1")))

You are using Java use Python instead and waits.

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

Imports:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading