I am trying to target email text field inside form which resides in iframe .

<div class="iframecontainer">
    <div class="iframe">
      <div class="headerText resultHeader">Result:</div>
      <div class="iframewrapper">
        <iframe id="iframeResult" class="result_output" frameborder="0" name="view" xsrc="tryhtml_input_readonly.htm">
    <!DOCTYPE html>

    <form action="demo_form.asp">
         **Email**: <input type="text" name="email"><br>
        Country: <input type="text" name="country" value="Norway" readonly><br>
        <input type="submit" value="Submit">
      <div class="footerText">Try it Yourself - &copy; <a href="http://www.w3schools.com">w3schools.com</a></div>      

Can anyone please help me to do it with Watir-webdriver

  • Have you tried using xpath? It searches based on the dom-tree. xpath-tutorial – AndrasCsanyi Apr 14 '15 at 8:46
  • 1
    You'll need to switch focus to the iframe window. Please search StackOverflow for answers and then show us your code if you're still having trouble. – FDM Apr 14 '15 at 10:08
  • @SayusiAndo I have been using this @browser.frame(:id=> "iframeResult" ) to locate the frame , but it always it is returning me "false" . is there any way – Rad N Apr 15 '15 at 4:42
  • @FDM : I am trying to find out that on stack-overflow , i did not get solution . can you please help me – Rad N Apr 15 '15 at 4:44
  • 1
    I voted to close this question as unclear what you are asking, because without more information its not possible to answer this question. We also need the (ruby) code you are currently using to drive the watir-webdriver test. – Niels van Reijmersdal Apr 20 '15 at 18:11

In order to access elements in frames you first need to switch to them.

Try to use driver.switch_to.frame "iframeResult" first and afterwards try to find or interact with the input elements.

  • This should really be a comment - you should either delete your answer and post this as a comment, or expand on your answer. – Kate Paulk Apr 15 '15 at 12:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.