2

I have the following html object inside an iframe:

html code for 'SUBMIT' button

I need to find it's XPath in order to click on the "SUBMIT" button but cannot find it. XPath helper only shows "//iframe".

So far, I've tried:

submit = driver.find_elements_by_xpath("//iframe[@id='btnSubmit']")
submit.click

1 Answer 1

1

All content, which is inside a frame or iframe cannot be accesed without switching to iframe/frame. So firstly switch to frame content:

driver.switch_to.frame(driver.find_element_by_name("frame_name"))

or

driver.switch_to.frame(driver.find_element_by_xpath("//xpath/to/frame"))

Then you can locate your submit button and click on it:

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

Than switch to default content like this:

driver.switch_to.default_content()

Note: you have to add some imports:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.