How To Find Xpath For Button Within Iframe Using Python?
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
Solution 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.uiimportWebDriverWaitfrom selenium.webdriver.supportimport expected_conditions asEC
Post a Comment for "How To Find Xpath For Button Within Iframe Using Python?"