How to fill value in text field with in iframe How to fill value in text field with in iframe selenium selenium

How to fill value in text field with in iframe


This is ruby code with selenium to switch in iframe. you can do it by:

#Move into iframepage.driver.browser.switch_to.frame "name or id of frame"#Move to default content or outsite framepage.driver.browser.switch_to.default_content


If you want to do any thing inside the frame. First you have to go inside the frame.

Code to enter the frame:

  //Assume driver is initiated properly some where.  driver.switchTo.frame(FrameName);(Or)    driver.switchTo.frame(FrameIndexValue);  (Or)    WebElement element = driver.findElement(By.id(LocatorValue));    driver.switchTo.frame(element);

After finishing your action inside the frame. You have to come out to frame by using

code to leave the frame:

  driver.switchTo.defaultContent();

If you are dealing with the iframe then the defaultContent() will take you to the main page above all the iframes, but if you deal with the frame this method will take you to the first frame of the page.

For more information on frame handling.