FAQ

[selenium-users] Unable to Select Element inside an Iframe

Mike Hill
Sep 20, 2012 at 10:47 am
I've been trying to select an element inside and iframe. The iframe has the
id of documentIFrame.

I switch to the iframe using this code
driver.SwitchTo().Frame("documentIFrame");

then i try and find the field using its id of HasRestrictedDemographics
using this code
driver.FindElement(By.Id("HasRestrictedDemographics"));

i've tried all different ways i.e Xpath, Css etc etc.

I cant see why its not working.

Thanks

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ.
For more options, visit https://groups.google.com/groups/opt_out.
reply

Search Discussions

31 responses

  • Peter Gale at Sep 20, 2012 at 10:57 am
    Talking about content editable iFrams, this page: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions

    ... suggests using a driver.switchTo().activeElement() command.

    This action seemed to fix a different iFrame issue in another post yesterday, though I have no idea why it did that.

    It might be worth trying it in your page.

    Date: Thu, 20 Sep 2012 03:40:13 -0700
    From: mik...@...com
    To: selenium-users@googlegroups.com
    Subject: [selenium-users] Unable to Select Element inside an Iframe

    I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.
    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this codedriver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.
    Thanks



    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 20, 2012 at 11:23 am
    Hi, i've read the information and i'm trying to find a check box and check
    it (althought i haven't uncluded the click command).

    And what HTML do you need as there is alot so i'll only post relative "bits"


    Thanks
    On Thursday, 20 September 2012 11:57:19 UTC+1, PeterJef...@Hotmail.co.uk
    wrote:
    Talking about content editable iFrams, this page:
    http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions

    ... suggests using a driver.switchTo().activeElement() command.

    This action seemed to fix a different iFrame issue in another post
    yesterday, though I have no idea why it did that.

    It might be worth trying it in your page.

    ------------------------------
    Date: Thu, 20 Sep 2012 03:40:13 -0700
    From: mi...@hill-web.com <javascript:>
    To: seleniu...@googlegroups.com <javascript:>
    Subject: [selenium-users] Unable to Select Element inside an Iframe

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/fM5dbeGsaiwJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jeevan at Sep 20, 2012 at 11:24 am
    Have you tried with the option given by Peter? If it didn't worked out then
    provide us the small bit of html code for the below:
    Frame tag and the element you want to click...

    Thanks,
    Jeevan.

    On Thu, Sep 20, 2012 at 4:46 PM, Mike Hill wrote:

    Hi, i've read the information and i'm trying to find a check box and check
    it (althought i haven't uncluded the click command).

    And what HTML do you need as there is alot so i'll only post relative
    "bits"


    Thanks
    On Thursday, 20 September 2012 11:57:19 UTC+1, PeterJef...@Hotmail.co.ukwrote:
    Talking about content editable iFrams, this page:
    http://code.google.com/p/**selenium/wiki/**FrequentlyAskedQuestions<http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions>

    ... suggests using a driver.switchTo().**activeElement() command.

    This action seemed to fix a different iFrame issue in another post
    yesterday, though I have no idea why it did that.

    It might be worth trying it in your page.

    ------------------------------
    Date: Thu, 20 Sep 2012 03:40:13 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.**com

    Subject: [selenium-users] Unable to Select Element inside an Iframe

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/**
    msg/selenium-users/-/Vo-**caftfMZgJ<https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ>
    .
    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/fM5dbeGsaiwJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jeevan at Sep 20, 2012 at 11:01 am
    Error stack and HTML code please.....
    On Thu, Sep 20, 2012 at 4:10 PM, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Timur Nurlygayanov at Sep 20, 2012 at 1:00 pm
    Probably in this case you have few frames on one page?

    Can you plese send example of html code of page?
    On Thu, Sep 20, 2012 at 2:40 PM, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Gale at Sep 20, 2012 at 1:03 pm
    have a look at: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions

    ... under "how do I type into a content editable iFrame?"

    Date: Thu, 20 Sep 2012 14:44:33 +0400
    Subject: Re: [selenium-users] Unable to Select Element inside an Iframe
    From: tnu...@...com
    To: selenium-users@googlegroups.com

    Probably in this case you have few frames on one page?

    Can you plese send example of html code of page?

    On Thu, Sep 20, 2012 at 2:40 PM, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.

    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.

    Thanks



    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ.

    For more options, visit https://groups.google.com/groups/opt_out.










    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 20, 2012 at 1:22 pm
    Hi, I've tried peter's way, which didn't work.

    The html for the iframe below:

    <iframe id="documentIFrame"
    src="../../PatientSettings/Get/111%20111%201111" frameborder="0"
    width="100%" height="788.8000030517578">&lt;p&gt;Your browser does not
    support iframes.&lt;/p&gt;</iframe>

    <input id="HasRestrictedDemographics" name="HasRestrictedDemographics"
    type="checkbox" value="true">
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ppNmbSvtungJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jeevan at Sep 20, 2012 at 1:44 pm
    WebElement iFrame= driver.findElement(By.id(" documentIFrame "));
    driver.SwitchTo().Frame(iFrame);

    and then try to find the element..

    Thanks,
    jeevan.

    On Thu, Sep 20, 2012 at 6:52 PM, Mike Hill wrote:

    Hi, I've tried peter's way, which didn't work.

    The html for the iframe below:

    <iframe id="documentIFrame"
    src="../../PatientSettings/Get/111%20111%201111" frameborder="0"
    width="100%" height="788.8000030517578">&lt;p&gt;Your browser does not
    support iframes.&lt;/p&gt;</iframe>

    <input id="HasRestrictedDemographics" name="HasRestrictedDemographics"
    type="checkbox" value="true">
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/ppNmbSvtungJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 20, 2012 at 2:00 pm
    Hi i tried that still nothing.

    Heres the stack trace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.RestrictedDemographics() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1175

    On Thursday, 20 September 2012 14:44:31 UTC+1, jeev wrote:

    WebElement iFrame= driver.findElement(By.id(" documentIFrame "));
    driver.SwitchTo().Frame(iFrame);

    and then try to find the element..

    Thanks,
    jeevan.


    On Thu, Sep 20, 2012 at 6:52 PM, Mike Hill <mi...@hill-web.com<javascript:>
    wrote:
    Hi, I've tried peter's way, which didn't work.

    The html for the iframe below:

    <iframe id="documentIFrame"
    src="../../PatientSettings/Get/111%20111%201111" frameborder="0"
    width="100%" height="788.8000030517578">&lt;p&gt;Your browser does not
    support iframes.&lt;/p&gt;</iframe>

    <input id="HasRestrictedDemographics" name="HasRestrictedDemographics"
    type="checkbox" value="true">
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/ppNmbSvtungJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/0iBGlEGG-ioJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jeevan at Sep 20, 2012 at 3:42 pm
    Ok...can you check the page source after you switch to iframe. Like:

    String source = driver.getPageSource();

    Verify whether element presents or not.

    Thanks,
    Jeevan


    On Thu, Sep 20, 2012 at 7:29 PM, Mike Hill wrote:

    Hi i tried that still nothing.

    Heres the stack trace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.RestrictedDemographics() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1175

    On Thursday, 20 September 2012 14:44:31 UTC+1, jeev wrote:

    WebElement iFrame= driver.findElement(**By.id(" documentIFrame "));
    driver.SwitchTo().Frame(iFrame**);

    and then try to find the element..

    Thanks,
    jeevan.

    On Thu, Sep 20, 2012 at 6:52 PM, Mike Hill wrote:

    Hi, I've tried peter's way, which didn't work.

    The html for the iframe below:

    <iframe id="documentIFrame" src="../../PatientSettings/**Get/111%20111%201111"
    frameborder="0" width="100%" height="788.8000030517578">&**lt;p&gt;Your
    browser does not support iframes.&lt;/p&gt;</iframe>

    <input id="HasRestrictedDemographics" name="**HasRestrictedDemographics"
    type="checkbox" value="true">
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**docum**entIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasR**estrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/**
    msg/selenium-users/-/**ppNmbSvtungJ<https://groups.google.com/d/msg/selenium-users/-/ppNmbSvtungJ>
    .

    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/0iBGlEGG-ioJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Justin Gourley at Sep 20, 2012 at 6:28 pm
    Based on the HTML you provided below, it looks like this
    "HasRestrictedDemographics" element is outside of the iFrame (exists below
    iFrame close). Therefore you will not want to select the frame, and just
    grab the element from the get go. Unless there is another iFrame on the
    page that the element falls inside of. In that case select that outer frame
    that the element is inside of.

    -Justin
    On Thu, Sep 20, 2012 at 3:40 AM, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/Vo-caftfMZgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 7:50 am
    Does this help more?

    <iframe id="documentIFrame" width="100%" height="767.5" frameborder="0"
    src="../../PatientSettings/Get/111%20111%201111">
         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
         <html xmlns="http://www.w3.org/1999/xhtml">
         <head>
             <body>
                 <table id="tblPage">
                     <tbody>
                         <tr>
                             <td>
                                 <div class="page" style="display: inline">
                                     <div id="header">
                                         <div style="clear: both; display:
    block;">
                                         </div>
                                         <div id="main">
                                             <form method="post"
    action="/testing/Gateway/PatientSettings/Get/111 111 1111">
                                             <div class="tabs ui-tabs ui-widget
    ui-widget-content ui-corner-all">
                                                 <div class="patSettingsField">
                                                     <div id="patientNumberDiv"
    style="display: none;">
                                                         <div
    class="patSettingsLabel">
                                                             <span
    class="patSettingsInfo"><span>
                                                                 <input
    id="HasRestrictedDemographics" type="checkbox" value="true"
    name="HasRestrictedDemographics">
                                                                 <input
    type="hidden" value="false" name="HasRestrictedDemographics">
                                                             </span>
                                                                 <div>
                                                                     <div
    id="changesSaved" class="patSettingsChangesSaved" style="display: none;">
                                                                         Changes
    saved
                                                                     </div>
                                                                 </div>
                                                         </div>
                                             </form>
                                         </div>
                                         <div style="clear: both; display:
    block;">
                                         </div>
                                         <div id="footer">
                                         </div>
                             </td>
                             <td>
                         </tr>
                     </tbody>
                 </table>
                 <div id="ui-datepicker-div" class="ui-datepicker ui-widget
    ui-widget-content ui-helper-clearfix ui-corner-all">
                 </div>
             </body>
         </html>
    </iframe>
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/T3uSKiF9EAwJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Gale at Sep 21, 2012 at 8:18 am
    Mike

    We can't tell if it's the switching to the iFrame that is failing, or the finding an element for in the iFrame that fails.

    Can you try running code to switch to the iFrame and then just run a find all elements using Xpath of "//*" ... loop through that list and output the tag name for each element.

    Once we know the switching works we can try to see if/why the find element fails.

    Peter

    Date: Fri, 21 Sep 2012 00:45:29 -0700
    From: mik...@...com
    To: selenium-users@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    Does this help more?
    <iframe id="documentIFrame" width="100%" height="767.5" frameborder="0" src="../../PatientSettings/Get/111%20111%201111"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <body> <table id="tblPage"> <tbody> <tr> <td> <div class="page" style="display: inline"> <div id="header"> <div style="clear: both; display: block;"> </div> <div id="main"> <form method="post" action="/testing/Gateway/PatientSettings/Get/111 111 1111"> <div class="tabs ui-tabs ui-widget ui-widget-content ui-corner-all"> <div class="patSettingsField"> <div id="patientNumberDiv" style="display: none;"> <div class="patSettingsLabel"> <span class="patSettingsInfo"><span> <input id="HasRestrictedDemographics" type="checkbox" value="true" name="HasRestrictedDemographics"> <input type="hidden" value="false" name="HasRestrictedDemographics"> </span> <div> <div id="changesSaved" class="patSettingsChangesSaved" style="display: none;"> Changes saved </div> </div> </div> </form> </div> <div style="clear: both; display: block;"> </div> <div id="footer"> </div> </td> <td> </tr> </tbody> </table> <div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"> </div> </body> </html></iframe>On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.
    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this codedriver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.
    Thanks



    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/T3uSKiF9EAwJ.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 8:41 am
    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside the
    iframe. At that point it fails (which is what i hoped for).
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Krishnan Mahadevan at Sep 21, 2012 at 8:49 am
    Mike,
    Lets go over this one more time.

    After you have switched to the iframe, have you tried finding any element
    inside it ? Does it fail for all elements or only this element alone ? If
    it fails to find your particular element alone [
    viz., HasRestrictedDemographics] then perhaps some javascript/ajax call is
    adding that element into the dom and you are trying to find it before it is
    done.. This is just a guess.

    So I would urge you to try this and see what happens .

    driver.SwitchTo().Frame("**documentIFrame");
    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");


    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive, fattening
    or in love with someone else!"


    On Fri, Sep 21, 2012 at 2:11 PM, Mike Hill wrote:

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 8:59 am
    So i've done that this is the fail message i get:

    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stack Trace:

    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    The line it fails on is this:

    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");
    On Friday, 21 September 2012 09:49:44 UTC+1, Krishnan wrote:

    Mike,
    Lets go over this one more time.

    After you have switched to the iframe, have you tried finding any element
    inside it ? Does it fail for all elements or only this element alone ? If
    it fails to find your particular element alone [
    viz., HasRestrictedDemographics] then perhaps some javascript/ajax call is
    adding that element into the dom and you are trying to find it before it is
    done.. This is just a guess.

    So I would urge you to try this and see what happens .

    driver.SwitchTo().Frame("**documentIFrame");
    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");


    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive, fattening
    or in love with someone else!"



    On Fri, Sep 21, 2012 at 2:11 PM, Mike Hill <mi...@hill-web.com<javascript:>
    wrote:
    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/y9elNU-88cUJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Krishnan Mahadevan at Sep 21, 2012 at 9:12 am
    Mike,

    So that kinda confirms my hunch. You are not in the intended frame to begin
    with.

    Are you beginning your test itself with this switching, or does your code
    do a switch to some other frame before ? If there are other frames wherein
    you might have switched, then you would need to switchto default content.

    Here's a simple java program that shows that switching to frames does work
    on normal terms.

    @Test
    public void foo() {
    FirefoxDriver fd = new FirefoxDriver();
    fd.get("http://www.packagemapping.com/example1.htm");
    fd.switchTo().frame("frame_track");
    String value = fd.findElement(By.id("tracknum")).getAttribute("value");
    System.out.println("value = " + value);
    fd.switchTo().defaultContent();
    fd.quit();
    }


    value = 1Z12345E1512345676
    PASSED: foo



    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive, fattening
    or in love with someone else!"


    On Fri, Sep 21, 2012 at 2:29 PM, Mike Hill wrote:

    So i've done that this is the fail message i get:

    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stack Trace:

    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    The line it fails on is this:

    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");
    On Friday, 21 September 2012 09:49:44 UTC+1, Krishnan wrote:

    Mike,
    Lets go over this one more time.

    After you have switched to the iframe, have you tried finding any element
    inside it ? Does it fail for all elements or only this element alone ? If
    it fails to find your particular element alone [ viz., **HasRestrictedDemographics]
    then perhaps some javascript/ajax call is adding that element into the dom
    and you are trying to find it before it is done.. This is just a guess.

    So I would urge you to try this and see what happens .

    driver.SwitchTo().Frame("**docum**entIFrame");
    driver.FindElement(By.Id("**tblPage")).GetAttribute("**innerHTML");


    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive,
    fattening or in love with someone else!"


    On Fri, Sep 21, 2012 at 2:11 PM, Mike Hill wrote:

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**docum**entIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasR**estrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/**
    msg/selenium-users/-/**lhb9kcRTLA0J<https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J>
    .
    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/y9elNU-88cUJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 9:01 am
    Krishnan,

    After i've switched to the iframe i have tried to find several elements.
    All of which it couldn't find.

    I'll try your code now.
    On Friday, 21 September 2012 09:49:44 UTC+1, Krishnan wrote:

    Mike,
    Lets go over this one more time.

    After you have switched to the iframe, have you tried finding any element
    inside it ? Does it fail for all elements or only this element alone ? If
    it fails to find your particular element alone [
    viz., HasRestrictedDemographics] then perhaps some javascript/ajax call is
    adding that element into the dom and you are trying to find it before it is
    done.. This is just a guess.

    So I would urge you to try this and see what happens .

    driver.SwitchTo().Frame("**documentIFrame");
    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");


    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive, fattening
    or in love with someone else!"



    On Fri, Sep 21, 2012 at 2:11 PM, Mike Hill <mi...@hill-web.com<javascript:>
    wrote:
    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/k_Z9ededWKIJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jeevan at Sep 21, 2012 at 8:58 am
    This means switch to frame is not happening....finally we can try to get
    the page source after we switch to the iframe and manually search for the
    element.


    On Fri, Sep 21, 2012 at 2:25 PM, Mike Hill wrote:

    Krishnan,

    After i've switched to the iframe i have tried to find several elements.
    All of which it couldn't find.

    I'll try your code now.
    On Friday, 21 September 2012 09:49:44 UTC+1, Krishnan wrote:

    Mike,
    Lets go over this one more time.

    After you have switched to the iframe, have you tried finding any element
    inside it ? Does it fail for all elements or only this element alone ? If
    it fails to find your particular element alone [ viz., **HasRestrictedDemographics]
    then perhaps some javascript/ajax call is adding that element into the dom
    and you are trying to find it before it is done.. This is just a guess.

    So I would urge you to try this and see what happens .

    driver.SwitchTo().Frame("**docum**entIFrame");
    driver.FindElement(By.Id("**tblPage")).GetAttribute("**innerHTML");


    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive,
    fattening or in love with someone else!"


    On Fri, Sep 21, 2012 at 2:11 PM, Mike Hill wrote:

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).
    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("**docum**entIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("**HasR**estrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/**
    msg/selenium-users/-/**lhb9kcRTLA0J<https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J>
    .
    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/k_Z9ededWKIJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Gale at Sep 21, 2012 at 9:06 am
    So can you show us what you have done and what the output was?

    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mik...@...com
    To: selenium-users@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,
    After the switch to the iframe, i've tried to click on elements outside the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.
    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this codedriver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.
    Thanks



    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 10:21 am
    So this is the code i used:

                 driver.Navigate();
                 driver.FindElement(By.Id("UserName")).SendKeys("testuser");
                 driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef");
                 driver.FindElement(By.Id("LoginButton")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
                 driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833
    8910");
                 driver.FindElement(By.Id("btnSearch")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

    driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
                 driver.SwitchTo().Frame("documentIFrame");
                 driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();


    The outcome:
    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stacktrace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest()



    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.uk
    wrote:
    So can you show us what you have done and what the output was?

    ------------------------------
    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com <javascript:>
    To: seleniu...@googlegroups.com <javascript:>
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks


    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Gale at Sep 21, 2012 at 10:29 am
    Is that the full stacktrace? ... I'd expect an "element not found" error to tell us more, like which element it was looking for and which line of code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering out important information doesn't help so giving the full stack trace is the best option

    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mik...@...com
    To: selenium-users@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:
                 driver.Navigate(); driver.FindElement(By.Id("UserName")).SendKeys("testuser"); driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef"); driver.FindElement(By.Id("LoginButton")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833 8910"); driver.FindElement(By.Id("btnSearch")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.SwitchTo().Frame("documentIFrame"); driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML"); //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();

    The outcome:Gateway.PatientSearchResults.DocumentTest:OpenQA.Selenium.NoSuchElementException : The element could not be found
    Stacktrace:at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)at OpenQA.Selenium.By.FindElement(ISearchContext context)at Gateway.PatientSearchResults.DocumentTest()


    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    So can you show us what you have done and what the output was?

    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,
    After the switch to the iframe, i've tried to click on elements outside the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.
    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this codedriver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.
    Thanks




    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.

    For more options, visit https://groups.google.com/groups/opt_out.









    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 10:33 am
    Yeah i noticed that, i'll run again and see if it gives more info.


    Yup ran again gives the line now :S weirdness!:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    line 1245 = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.uk
    wrote:
    Is that the full stacktrace? ... I'd expect an "element not found" error
    to tell us more, like which element it was looking for and which line of
    code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering
    out important information doesn't help so giving the full stack trace is
    the best option

    ------------------------------
    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com <javascript:>
    To: seleniu...@googlegroups.com <javascript:>
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:

    driver.Navigate();
    driver.FindElement(By.Id("UserName")).SendKeys("testuser");
    driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef");
    driver.FindElement(By.Id("LoginButton")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833
    8910");
    driver.FindElement(By.Id("btnSearch")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

    driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.SwitchTo().Frame("documentIFrame");
    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();


    The outcome:
    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stacktrace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest()



    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So can you show us what you have done and what the output was?

    ------------------------------
    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks


    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Gale at Sep 21, 2012 at 10:43 am
    So it's clealy ok with finding the iFrame and trying to switch to it, but yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

         driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait .. there's a "wait for element" to be visible method soemwhere, but I can't say where it is off the top of my head.

    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mik...@...com
    To: selenium-users@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.

    Yup ran again gives the line now :S weirdness!:at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)at OpenQA.Selenium.By.FindElement(ISearchContext context)at Gateway.PatientSearchResults.DocumentTest() in C:\Users\mhill\Documents\Visual Studio 2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245
    line 1245 = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");
    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    Is that the full stacktrace? ... I'd expect an "element not found" error to tell us more, like which element it was looking for and which line of code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering out important information doesn't help so giving the full stack trace is the best option

    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:
                 driver.Navigate(); driver.FindElement(By.Id("UserName")).SendKeys("testuser"); driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef"); driver.FindElement(By.Id("LoginButton")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833 8910"); driver.FindElement(By.Id("btnSearch")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.SwitchTo().Frame("documentIFrame"); driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML"); //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();

    The outcome:Gateway.PatientSearchResults.DocumentTest:OpenQA.Selenium.NoSuchElementException : The element could not be found
    Stacktrace:at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)at OpenQA.Selenium.By.FindElement(ISearchContext context)at Gateway.PatientSearchResults.DocumentTest()


    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    So can you show us what you have done and what the output was?

    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,
    After the switch to the iframe, i've tried to click on elements outside the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.
    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this codedriver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.
    Thanks




    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.

    For more options, visit https://groups.google.com/groups/opt_out.










    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.

    For more options, visit https://groups.google.com/groups/opt_out.









    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 10:46 am
    So i did a simple thread.sleep(5000); after switching to the iframe.

    It still fails on the same line of code as before :S

    On Friday, 21 September 2012 11:44:01 UTC+1, PeterJef...@Hotmail.co.uk
    wrote:
    So it's clealy ok with finding the iFrame and trying to switch to it, but
    yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

    driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has
    registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait ..
    there's a "wait for element" to be visible method soemwhere, but I can't
    say where it is off the top of my head.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mi...@hill-web.com <javascript:>
    To: seleniu...@googlegroups.com <javascript:>
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.


    Yup ran again gives the line now :S weirdness!:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    line 1245 = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Is that the full stacktrace? ... I'd expect an "element not found" error
    to tell us more, like which element it was looking for and which line of
    code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering
    out important information doesn't help so giving the full stack trace is
    the best option

    ------------------------------
    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:

    driver.Navigate();
    driver.FindElement(By.Id("UserName")).SendKeys("testuser");
    driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef");
    driver.FindElement(By.Id("LoginButton")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833
    8910");
    driver.FindElement(By.Id("btnSearch")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

    driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.SwitchTo().Frame("documentIFrame");
    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();


    The outcome:
    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stacktrace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest()



    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So can you show us what you have done and what the output was?

    ------------------------------
    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks


    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/7LDoIH6KJ00J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Gale at Sep 21, 2012 at 10:52 am
    Ok ... so it's switching to the iFrame but not registering the content. We need something to trigger the loading of the content.

    I think that's what this line:
        driver.switchTo().activeElement();

    as used here: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_How_do_I_type_into_a_contentEditable_iframe?
    ... is supposed to do.

    Krishnan's code ash this line:

        switchTo().defaultContent();

    which I presume does a similar thing.

    Can you try each of these lines after the sleep and if either makes it work, then remove the sleep and see if it still works.

    Date: Fri, 21 Sep 2012 03:46:46 -0700
    From: mik...@...com
    To: selenium-users@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So i did a simple thread.sleep(5000); after switching to the iframe.
    It still fails on the same line of code as before :S

    On Friday, 21 September 2012 11:44:01 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    So it's clealy ok with finding the iFrame and trying to switch to it, but yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

         driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait .. there's a "wait for element" to be visible method soemwhere, but I can't say where it is off the top of my head.

    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.

    Yup ran again gives the line now :S weirdness!:at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)at OpenQA.Selenium.By.FindElement(ISearchContext context)at Gateway.PatientSearchResults.DocumentTest() in C:\Users\mhill\Documents\Visual Studio 2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245
    line 1245 = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");
    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    Is that the full stacktrace? ... I'd expect an "element not found" error to tell us more, like which element it was looking for and which line of code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering out important information doesn't help so giving the full stack trace is the best option

    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:
                 driver.Navigate(); driver.FindElement(By.Id("UserName")).SendKeys("testuser"); driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef"); driver.FindElement(By.Id("LoginButton")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833 8910"); driver.FindElement(By.Id("btnSearch")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.SwitchTo().Frame("documentIFrame"); driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML"); //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();

    The outcome:Gateway.PatientSearchResults.DocumentTest:OpenQA.Selenium.NoSuchElementException : The element could not be found
    Stacktrace:at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)at OpenQA.Selenium.By.FindElement(ISearchContext context)at Gateway.PatientSearchResults.DocumentTest()


    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    So can you show us what you have done and what the output was?

    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,
    After the switch to the iframe, i've tried to click on elements outside the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.
    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this codedriver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.
    Thanks




    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.

    For more options, visit https://groups.google.com/groups/opt_out.










    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.

    For more options, visit https://groups.google.com/groups/opt_out.










    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.

    For more options, visit https://groups.google.com/groups/opt_out.









    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/7LDoIH6KJ00J.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 10:56 am
    Still failing on
    the driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:52:41 UTC+1, PeterJef...@Hotmail.co.uk
    wrote:
    Ok ... so it's switching to the iFrame but not registering the content.
    We need something to trigger the loading of the content.

    I think that's what this line:

    driver.switchTo().activeElement();

    as used here: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_How_do_I_type_into_a_contentEditable_iframe?

    ... is supposed to do.

    Krishnan's code ash this line:

    switchTo().defaultContent();

    which I presume does a similar thing.

    Can you try each of these lines after the sleep and if either makes it
    work, then remove the sleep and see if it still works.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:46:46 -0700
    From: mi...@hill-web.com <javascript:>
    To: seleniu...@googlegroups.com <javascript:>
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So i did a simple thread.sleep(5000); after switching to the iframe.

    It still fails on the same line of code as before :S

    On Friday, 21 September 2012 11:44:01 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So it's clealy ok with finding the iFrame and trying to switch to it, but
    yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

    driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has
    registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait ..
    there's a "wait for element" to be visible method soemwhere, but I can't
    say where it is off the top of my head.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.


    Yup ran again gives the line now :S weirdness!:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    line 1245 = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Is that the full stacktrace? ... I'd expect an "element not found" error
    to tell us more, like which element it was looking for and which line of
    code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering
    out important information doesn't help so giving the full stack trace is
    the best option

    ------------------------------
    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:

    driver.Navigate();
    driver.FindElement(By.Id("UserName")).SendKeys("testuser");
    driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef");
    driver.FindElement(By.Id("LoginButton")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833
    8910");
    driver.FindElement(By.Id("btnSearch")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

    driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.SwitchTo().Frame("documentIFrame");
    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();


    The outcome:
    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stacktrace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest()



    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So can you show us what you have done and what the output was?

    ------------------------------
    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks


    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/7LDoIH6KJ00J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/z3dm_H41vX8J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Peter Gale at Sep 21, 2012 at 11:47 am
    At this stage, if neither ... driver.switchTo().activeElement();

    nor ... switchTo().defaultContent();
    ... helps then I'm all out of ideas.

    Something other than a findElements needs to be done here, but I've no idea what, and I think we made all the known recommendations I've seen.

    Could it be that something needs triggering in the AUT to activate the iFrame? Maybe the manual user's actions trigger something else were not aware of?

    I can only suggest having one of the local developers who has worked on the app sit with you to try to understand what you are trying to do and see if they can make sense of what is happening in the app.


    Date: Fri, 21 Sep 2012 03:56:49 -0700
    From: mik...@...com
    To: selenium-users@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Still failing on the driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:52:41 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    Ok ... so it's switching to the iFrame but not registering the content. We need something to trigger the loading of the content.

    I think that's what this line:
        driver.switchTo().activeElement();

    as used here: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_How_do_I_type_into_a_contentEditable_iframe?
    ... is supposed to do.

    Krishnan's code ash this line:

        switchTo().defaultContent();

    which I presume does a similar thing.

    Can you try each of these lines after the sleep and if either makes it work, then remove the sleep and see if it still works.

    Date: Fri, 21 Sep 2012 03:46:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So i did a simple thread.sleep(5000); after switching to the iframe.
    It still fails on the same line of code as before :S

    On Friday, 21 September 2012 11:44:01 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    So it's clealy ok with finding the iFrame and trying to switch to it, but yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

         driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait .. there's a "wait for element" to be visible method soemwhere, but I can't say where it is off the top of my head.

    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.

    Yup ran again gives the line now :S weirdness!:at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)at OpenQA.Selenium.By.FindElement(ISearchContext context)at Gateway.PatientSearchResults.DocumentTest() in C:\Users\mhill\Documents\Visual Studio 2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245
    line 1245 = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");
    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    Is that the full stacktrace? ... I'd expect an "element not found" error to tell us more, like which element it was looking for and which line of code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering out important information doesn't help so giving the full stack trace is the best option

    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:
                 driver.Navigate(); driver.FindElement(By.Id("UserName")).SendKeys("testuser"); driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef"); driver.FindElement(By.Id("LoginButton")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833 8910"); driver.FindElement(By.Id("btnSearch")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); driver.SwitchTo().Frame("documentIFrame"); driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML"); //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();

    The outcome:Gateway.PatientSearchResults.DocumentTest:OpenQA.Selenium.NoSuchElementException : The element could not be found
    Stacktrace:at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)at OpenQA.Selenium.By.FindElement(ISearchContext context)at Gateway.PatientSearchResults.DocumentTest()


    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.uk wrote:



    So can you show us what you have done and what the output was?

    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,
    After the switch to the iframe, i've tried to click on elements outside the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:I've been trying to select an element inside and iframe. The iframe has the id of documentIFrame.
    I switch to the iframe using this codedriver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics using this codedriver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.
    I cant see why its not working.
    Thanks




    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.

    For more options, visit https://groups.google.com/groups/opt_out.










    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.

    For more options, visit https://groups.google.com/groups/opt_out.










    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.

    For more options, visit https://groups.google.com/groups/opt_out.










    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to seleniu...@googlegroups.com.

    To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/7LDoIH6KJ00J.

    For more options, visit https://groups.google.com/groups/opt_out.









    --

    You received this message because you are subscribed to the Google Groups "Selenium Users" group.

    To post to this group, send email to selenium-users@googlegroups.com.

    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/z3dm_H41vX8J.

    For more options, visit https://groups.google.com/groups/opt_out.






    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mike Hill at Sep 21, 2012 at 12:27 pm
    Cheers for all your help, i'll speak to the dev's and see what happens :)

    On Friday, 21 September 2012 12:47:58 UTC+1, PeterJef...@Hotmail.co.uk
    wrote:
    At this stage, if neither ... driver.switchTo().activeElement();

    nor ... switchTo().defaultContent();

    ... helps then I'm all out of ideas.

    Something other than a findElements needs to be done here, but I've no
    idea what, and I think we made all the known recommendations I've seen.

    Could it be that something needs triggering in the AUT to activate the
    iFrame? Maybe the manual user's actions trigger something else were not
    aware of?

    I can only suggest having one of the local developers who has worked on
    the app sit with you to try to understand what you are trying to do and see
    if they can make sense of what is happening in the app.


    ------------------------------
    Date: Fri, 21 Sep 2012 03:56:49 -0700
    From: mi...@hill-web.com <javascript:>
    To: seleniu...@googlegroups.com <javascript:>
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Still failing on
    the driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:52:41 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Ok ... so it's switching to the iFrame but not registering the content.
    We need something to trigger the loading of the content.

    I think that's what this line:

    driver.switchTo().activeElement();

    as used here: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_How_do_I_type_into_a_contentEditable_iframe?

    ... is supposed to do.

    Krishnan's code ash this line:

    switchTo().defaultContent();

    which I presume does a similar thing.

    Can you try each of these lines after the sleep and if either makes it
    work, then remove the sleep and see if it still works.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:46:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So i did a simple thread.sleep(5000); after switching to the iframe.

    It still fails on the same line of code as before :S

    On Friday, 21 September 2012 11:44:01 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So it's clealy ok with finding the iFrame and trying to switch to it, but
    yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

    driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has
    registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait ..
    there's a "wait for element" to be visible method soemwhere, but I can't
    say where it is off the top of my head.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.


    Yup ran again gives the line now :S weirdness!:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    line 1245 = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Is that the full stacktrace? ... I'd expect an "element not found" error
    to tell us more, like which element it was looking for and which line of
    code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering
    out important information doesn't help so giving the full stack trace is
    the best option

    ------------------------------
    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an Iframe

    So this is the code i used:

    driver.Navigate();
    driver.FindElement(By.Id("UserName")).SendKeys("testuser");
    driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef");
    driver.FindElement(By.Id("LoginButton")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833
    8910");
    driver.FindElement(By.Id("btnSearch")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

    driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.SwitchTo().Frame("documentIFrame");
    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();


    The outcome:
    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stacktrace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest()



    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So can you show us what you have done and what the output was?

    ------------------------------
    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks


    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/7LDoIH6KJ00J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/z3dm_H41vX8J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/WiDcNNkBhN0J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Vivektests at Aug 22, 2013 at 9:43 am
    Mike,
    Facing similar issue.

    driver.switchTo().frame(1); // there is no ID or name to the iFrame

    // checked that there are only 2 iFrames 1 in the base page and the other in the popup

      try {
       System.out.println("Wait for the popup to get loaded");
       Thread.sleep(15000);
      } catch (InterruptedException e){
       System.out.println("Exception : " + e.getMessage());
      }

      driver.findElement(By.cssSelector("#tab3")).click(); // tab
      driver.findElement(By.cssSelector("#p1")).click(); // check box
      driver.findElement(By.cssSelector("#pNote")).click(); // text area
      driver.findElement(By.cssSelector("pButtonClose")).click(); // close button for the popup

      //switch out of the frame back to the main screen, probably this is not required, but not sure at this point
      driver.switchTo().defaultContent();

    Error I am getting =============================================

    org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":"#p1"}

    As you can see the error is not occuring when click on #tab3 is done (note: tab3 is selected by default then the popup opens)

    Not getting what I am missing here.
    Tried Issues search, googling and FAQ, unfortunately stuck!


    Can you please share if this got resolved for you and how.

    Thanks


    On Friday, September 21, 2012 5:57:15 PM UTC+5:30, Mike Hill wrote:

    Cheers for all your help, i'll speak to the dev's and see what happens :)

    On Friday, 21 September 2012 12:47:58 UTC+1, PeterJef...@Hotmail.co.ukwrote:
    At this stage, if neither ... driver.switchTo().activeElement();

    nor ... switchTo().defaultContent();

    ... helps then I'm all out of ideas.

    Something other than a findElements needs to be done here, but I've no
    idea what, and I think we made all the known recommendations I've seen.

    Could it be that something needs triggering in the AUT to activate the
    iFrame? Maybe the manual user's actions trigger something else were not
    aware of?

    I can only suggest having one of the local developers who has worked on
    the app sit with you to try to understand what you are trying to do and see
    if they can make sense of what is happening in the app.


    ------------------------------
    Date: Fri, 21 Sep 2012 03:56:49 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    Still failing on
    the driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:52:41 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Ok ... so it's switching to the iFrame but not registering the content.
    We need something to trigger the loading of the content.

    I think that's what this line:

    driver.switchTo().activeElement();

    as used here: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_How_do_I_type_into_a_contentEditable_iframe?

    ... is supposed to do.

    Krishnan's code ash this line:

    switchTo().defaultContent();

    which I presume does a similar thing.

    Can you try each of these lines after the sleep and if either makes it
    work, then remove the sleep and see if it still works.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:46:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    So i did a simple thread.sleep(5000); after switching to the iframe.

    It still fails on the same line of code as before :S

    On Friday, 21 September 2012 11:44:01 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So it's clealy ok with finding the iFrame and trying to switch to it,
    but yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

    driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has
    registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait ..
    there's a "wait for element" to be visible method soemwhere, but I can't
    say where it is off the top of my head.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.


    Yup ran again gives the line now :S weirdness!:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    line 1245
    = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Is that the full stacktrace? ... I'd expect an "element not found" error
    to tell us more, like which element it was looking for and which line of
    code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering
    out important information doesn't help so giving the full stack trace is
    the best option

    ------------------------------
    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    So this is the code i used:

    driver.Navigate();
    driver.FindElement(By.Id("UserName")).SendKeys("testuser");
    driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef");
    driver.FindElement(By.Id("LoginButton")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833
    8910");
    driver.FindElement(By.Id("btnSearch")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

    driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.SwitchTo().Frame("documentIFrame");

    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();


    The outcome:
    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stacktrace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest()



    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So can you show us what you have done and what the output was?

    ------------------------------
    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks


    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/7LDoIH6KJ00J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/z3dm_H41vX8J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7899f03b-8748-4302-b86b-424fa70507cf%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Kanimozhi vellaisamy at Dec 16, 2013 at 6:45 am
    Hi,

    Am facing the same issue. Did anybody arrived to a solution for this. It
    will be much help full, if anyone shares their thought.

    Thanks,
    Kani.
    On Thursday, 22 August 2013 12:48:56 UTC+5:30, Vivektests wrote:

    Mike,
    Facing similar issue.

    driver.switchTo().frame(1); // there is no ID or name to the iFrame

    // checked that there are only 2 iFrames 1 in the base page and the other in the popup

    try {
    System.out.println("Wait for the popup to get loaded");
    Thread.sleep(15000);
    } catch (InterruptedException e){
    System.out.println("Exception : " + e.getMessage());
    }

    driver.findElement(By.cssSelector("#tab3")).click(); // tab
    driver.findElement(By.cssSelector("#p1")).click(); // check box
    driver.findElement(By.cssSelector("#pNote")).click(); // text area
    driver.findElement(By.cssSelector("pButtonClose")).click(); // close button for the popup

    //switch out of the frame back to the main screen, probably this is not required, but not sure at this point
    driver.switchTo().defaultContent();

    Error I am getting =============================================

    org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":"#p1"}

    As you can see the error is not occuring when click on #tab3 is done (note: tab3 is selected by default then the popup opens)

    Not getting what I am missing here.
    Tried Issues search, googling and FAQ, unfortunately stuck!


    Can you please share if this got resolved for you and how.

    Thanks


    On Friday, September 21, 2012 5:57:15 PM UTC+5:30, Mike Hill wrote:

    Cheers for all your help, i'll speak to the dev's and see what happens :)

    On Friday, 21 September 2012 12:47:58 UTC+1, PeterJef...@Hotmail.co.ukwrote:
    At this stage, if neither ... driver.switchTo().activeElement();

    nor ... switchTo().defaultContent();

    ... helps then I'm all out of ideas.

    Something other than a findElements needs to be done here, but I've no
    idea what, and I think we made all the known recommendations I've seen.

    Could it be that something needs triggering in the AUT to activate the
    iFrame? Maybe the manual user's actions trigger something else were not
    aware of?

    I can only suggest having one of the local developers who has worked on
    the app sit with you to try to understand what you are trying to do and see
    if they can make sense of what is happening in the app.


    ------------------------------
    Date: Fri, 21 Sep 2012 03:56:49 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    Still failing on
    the driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:52:41 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Ok ... so it's switching to the iFrame but not registering the content.
    We need something to trigger the loading of the content.

    I think that's what this line:

    driver.switchTo().activeElement();

    as used here: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_How_do_I_type_into_a_contentEditable_iframe?

    ... is supposed to do.

    Krishnan's code ash this line:

    switchTo().defaultContent();

    which I presume does a similar thing.

    Can you try each of these lines after the sleep and if either makes it
    work, then remove the sleep and see if it still works.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:46:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    So i did a simple thread.sleep(5000); after switching to the iframe.

    It still fails on the same line of code as before :S

    On Friday, 21 September 2012 11:44:01 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So it's clealy ok with finding the iFrame and trying to switch to it,
    but yes, then it can't find any elements in the frame.

    I'd suggest putting an arbitary long wait after the lien:

    driver.SwitchTo().Frame("documentIFrame");

    ... say five seconds or so.

    it may be that the next line of code is executing before the page has
    registered the switch to the iFrame.

    If an arbitary wait wokrs, you can then change it to conditional wait ..
    there's a "wait for element" to be visible method soemwhere, but I can't
    say where it is off the top of my head.

    ------------------------------
    Date: Fri, 21 Sep 2012 03:33:37 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    Yeah i noticed that, i'll run again and see if it gives more info.


    Yup ran again gives the line now :S weirdness!:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest() in
    C:\Users\mhill\Documents\Visual Studio
    2010\Projects\TESTSelenium\TESTSelenium\Class1.cs:line 1245

    line 1245
    = driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    On Friday, 21 September 2012 11:29:23 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    Is that the full stacktrace? ... I'd expect an "element not found"
    error to tell us more, like which element it was looking for and which line
    of code it actually failed on.

    Ok ... maybe we don't *need* to see the full stack trace, but filtering
    out important information doesn't help so giving the full stack trace is
    the best option

    ------------------------------
    Date: Fri, 21 Sep 2012 03:21:25 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: Re: [selenium-users] Re: Unable to Select Element inside an
    Iframe

    So this is the code i used:

    driver.Navigate();
    driver.FindElement(By.Id("UserName")).SendKeys("testuser");
    driver.FindElement(By.Id("UserPWD")).SendKeys("abcdef");
    driver.FindElement(By.Id("LoginButton")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.FindElement(By.Id("txtPatientNo")).SendKeys("100 833
    8910");
    driver.FindElement(By.Id("btnSearch")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

    driver.FindElement(By.XPath("//*[@id='phMain_recordTree_tree_main']/div/div[4]/span[2]/span[2]")).Click();

    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
    driver.SwitchTo().Frame("documentIFrame");

    driver.FindElement(By.Id("tblPage")).GetAttribute("innerHTML");

    //driver.FindElement(By.Id("HasRestrictedDemographics")).Click();


    The outcome:
    Gateway.PatientSearchResults.DocumentTest:
    OpenQA.Selenium.NoSuchElementException : The element could not be found

    Stacktrace:
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
    errorResponse)
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
    driverCommandToExecute, Dictionary`2 parameters)
    at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism,
    String value)
    at OpenQA.Selenium.By.FindElement(ISearchContext context)
    at Gateway.PatientSearchResults.DocumentTest()



    On Friday, 21 September 2012 10:06:56 UTC+1, PeterJef...@Hotmail.co.ukwrote:

    So can you show us what you have done and what the output was?

    ------------------------------
    Date: Fri, 21 Sep 2012 01:41:46 -0700
    From: mi...@hill-web.com
    To: seleniu...@googlegroups.com
    Subject: [selenium-users] Re: Unable to Select Element inside an Iframe

    I've already done something similar,

    After the switch to the iframe, i've tried to click on elements outside
    the iframe. At that point it fails (which is what i hoped for).

    On Thursday, 20 September 2012 11:40:13 UTC+1, Mike Hill wrote:

    I've been trying to select an element inside and iframe. The iframe has
    the id of documentIFrame.

    I switch to the iframe using this code
    driver.SwitchTo().Frame("documentIFrame");

    then i try and find the field using its id of HasRestrictedDemographics
    using this code
    driver.FindElement(By.Id("HasRestrictedDemographics"));

    i've tried all different ways i.e Xpath, Css etc etc.

    I cant see why its not working.

    Thanks


    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/lhb9kcRTLA0J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/kCEZTTy6sdUJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/9iM-6QCYlWkJ.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/7LDoIH6KJ00J.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/z3dm_H41vX8J.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2faca06a-4e43-4d29-8e6d-7031e9d111cb%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions