1

i have written parameters in webpage & applying them by selecting apply button. 1. apply button is getting clicked for web elements outside frame using below command browser1.find_element_by_name("action").click()

  1. apply button not getting clicked when saving the paramters inside a frame of web page using same command browser1.find_element_by_name("action").click()
1

3 Answers 3

4

you need to switch to iframe

fist you need to find the iframe then switch to it then click

driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))

or you could use xpath to locate the element

driver.find_element_by_xpath("//iframe[]")

Sign up to request clarification or add additional context in comments.

1 Comment

you have no idea how happy I am, you solved my problem! thank you very much
0

I do not know the Python syntax, but in Selenium you have to switch to the frame much like you would switch to a new tab or window before performing your click.

The syntax in Java would be: driver.switchTo().frame();

Comments

0

As mentioned by the others:

 WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[]"))) #elements are in a iframe, have to select it first

If there is a chance that it doesn't show up immediately you might want to build in this wait function. Tells python to wait for max 10 secs, until frame is available and switches to it right away. I use Xpath to track down the iframe

Dont know how new you are, so provided the imports below:

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

Credit for this solution goes to @Andersson Finding xpaths on pages running script Upvote him there.

Couldn't find the duplicate report button. Title of this post makes it easier to find then the above mentioned question. (full disclosure, the link links to one of my own questions)

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.