FAQ
With Android Driver, I am observing driver.switchto.defaultcontent(); is
not working as expected.

As part of my test scenario, I have to verify something inside frame. I am
switching to frame before verifying and verification succeeds. After that I
am using switch to default content and then trying to click on X element
(which is outside the frame).
It is unable to find "X" element since default content is not switched back
properly.

When I try to find X element and Click without previous steps (switching to
frame and switch back to default content) it is working fine.
Anyone else observed this issue?

Note: Using Selenium 2.25
Android 4.0 [Emulator- Tablet Model]


Thanks,
Pavithra

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/F2g4Sl9AtwQJ.
To post to this group, send email to webdriver@googlegroups.com.
To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

Search Discussions

  • Pavithra at Sep 3, 2012 at 9:58 am
    Can someone please let me know how to achieve
    driver.switchto.defaultcontent(); in javascript?

    Thanks,
    Pavithra

    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/sMAnkk8PmMwJ.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Peter Gale at Sep 3, 2012 at 10:11 am
    I don't see that you will be able to simulate this in javascript, at least in your case .

    As you are hoping to move between iFrames, what you are trying to do is to tell WebDriver to look at a different frame (i.e. teh defaul one). if it worked, as you say it is not, you would not be changing anything on the page, or resetting/redirect any variable etc acceible to javascript.

    You would be acting on the WebDriver object only, and that is not exposed to to javascript.

    I think your only option is to persist with resolving the original problem, for which you might want to give more information ... html, test script.

    It's only been two days since you raised it, and they have been over a weekend, so it's still a bit early for getting a solutio, though adding that extra information might help.

    Date: Mon, 3 Sep 2012 02:58:21 -0700
    From: pavithz@gmail.com
    To: webdriver@googlegroups.com
    Subject: [webdriver] Re: Is there problem with Android driver with switchtodefcontent

    Can someone please let me know how to achieve driver.switchto.defaultcontent(); in javascript?

    Thanks,
    Pavithra




    --

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

    To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/sMAnkk8PmMwJ.

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

    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.


    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Pavithra at Sep 4, 2012 at 5:52 am
    Dom Structure looks like this:
    <html>
      <head>...</head>
      <body>..<script>..</script>
         <div class="main-view">
           <div class="mainview-wrpr">
              <div class="card sidecolumn">
                  <div class="messagelist>
                        <div class="base-sprite img-menu"></div>
                        <div class="hatheader></div>
                   </div>
                </div>
                <div class="card maincolumn>
                   <div class="a"/>
                   <div class="b"/>
                   <div class="c">
                       <div class="body container">
                             <div class="msgheader"/>
                             <div class="isScrollWrapper".....>
                                 <div class="cbody"...>
                                       <iframe src="about:Blank"
    frameborder="no" tabindex="-1" scrolling="no" name="msg-body-iframe"
    style="...";>
                                              <html>
                                                   <head>...</head>
                                                   <body class="abcd">
                                                         <div id="xyz">...</div>
                                                   </body>
                                               </html>
                                         </iframe>
                                   </div>
                              </div>
                        </div>
                  </div>
             </div>
    and so on....

    Now I want to perform something under iframe and used switchtoiframe using
    driver.switchto.frame("msg-body-iframe");

    Perform some action inside iframe.

    Now, I want to click on button with class name- base-sprite img-menu

    Before clicking, I used driver.switchto.defaultcontent();
    And, I identified the element by xpath, //div[@class='
    messagelist']/div[@class='base-sprite img-menu'] say element "goBack"
    Now while trying to click on the webelement - goBack.click(); it throws
    Element not found Exception.

    However, when I try to click on the same goBack element before switching to
    above iframe, it is getting clicked properly.

    If there is no way via javascript, is there any other way I can handle this?

    Note: I am not sure whether it's bug, anyway I raised issue:
    http://code.google.com/p/selenium/issues/detail?id=4500

    Thanks,
    Pavithra.


    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/pfKiB0zmEX0J.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Krishnan Mahadevan at Sep 4, 2012 at 6:06 am
    http://www.yourhtmlsource.com/javascript/scriptingframes.html
    http://www.pageresource.com/jscript/jframe1.htm

    Thanks & Regards
    Krishnan Mahadevan

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


    On Tue, Sep 4, 2012 at 11:22 AM, Pavithra wrote:

    Dom Structure looks like this:
    <html>
    <head>...</head>
    <body>..<script>..</script>
    <div class="main-view">
    <div class="mainview-wrpr">
    <div class="card sidecolumn">
    <div class="messagelist>
    <div class="base-sprite img-menu"></div>
    <div class="hatheader></div>
    </div>
    </div>
    <div class="card maincolumn>
    <div class="a"/>
    <div class="b"/>
    <div class="c">
    <div class="body container">
    <div class="msgheader"/>
    <div class="isScrollWrapper".....>
    <div class="cbody"...>
    <iframe src="about:Blank"
    frameborder="no" tabindex="-1" scrolling="no" name="msg-body-iframe"
    style="...";>
    <html>
    <head>...</head>
    <body class="abcd">
    <div id="xyz">...</div>
    </body>
    </html>
    </iframe>
    </div>
    </div>
    </div>
    </div>
    </div>
    and so on....

    Now I want to perform something under iframe and used switchtoiframe using
    driver.switchto.frame("msg-body-iframe");

    Perform some action inside iframe.

    Now, I want to click on button with class name- base-sprite img-menu

    Before clicking, I used driver.switchto.defaultcontent();
    And, I identified the element by xpath, //div[@class='
    messagelist']/div[@class='base-sprite img-menu'] say element "goBack"
    Now while trying to click on the webelement - goBack.click(); it throws
    Element not found Exception.

    However, when I try to click on the same goBack element before switching
    to above iframe, it is getting clicked properly.

    If there is no way via javascript, is there any other way I can handle
    this?

    Note: I am not sure whether it's bug, anyway I raised issue:
    http://code.google.com/p/selenium/issues/detail?id=4500

    Thanks,
    Pavithra.



    --
    You received this message because you are subscribed to the Google Groups
    "webdriver" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/webdriver/-/pfKiB0zmEX0J.

    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to
    webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/webdriver?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Pavithra at Sep 4, 2012 at 6:41 am
    Thanks Krishnan for the reference.

    Yesterday actually, I tried via javascript as below:
    ((JavascriptExecutor)
    driver).executeScript("self.parent.parent.parent.parent.window.focus()");

    Since, I was in iframe/html/body/div [I gave four parents so that it goes
    to iframe's parent and then focus] but still it didn't work. It doesn't
    throw any error.
    But, when I tried getting the element with xpath,/html/body/div I am still
    getting the element inside iframe and not the element outside iframe.

    From the api, I could understand that switchtodefaultcontent(); selects the
    main document when the page contains iframes. Here what does select mean?
    does it focus? What action, I need to do on the window (which I get via
    javascript) to come out of the frame ?

    Thanks,
    Pavithra

    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/vGROuCCCgJcJ.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Peter Gale at Sep 4, 2012 at 7:36 am
    Are you sure that switching frame in javascript swithches the frame that the webdriver object is looking at?

    Date: Mon, 3 Sep 2012 23:41:18 -0700
    From: pavithz@gmail.com
    To: webdriver@googlegroups.com
    Subject: Re: [webdriver] Re: Is there problem with Android driver with switchtodefcontent

    Thanks Krishnan for the reference.

    Yesterday actually, I tried via javascript as below:
    ((JavascriptExecutor) driver).executeScript("self.parent.parent.parent.parent.window.focus()");

    Since, I was in iframe/html/body/div [I gave four parents so that it goes to iframe's parent and then focus] but still it didn't work. It doesn't throw any error.
    But, when I tried getting the element with xpath,/html/body/div I am still getting the element inside iframe and not the element outside iframe.

    From the api, I could understand that switchtodefaultcontent(); selects the main document when the page contains iframes. Here what does select mean? does it focus? What action, I need to do on the window (which I get via javascript) to come out of the frame ?

    Thanks,
    Pavithra




    --

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

    To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/vGROuCCCgJcJ.

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

    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.


    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Krishnan Mahadevan at Sep 4, 2012 at 8:05 am
    Pavithra,
    Since you can use Javascript to toggle around between frames, why not stay
    in the parent window itself and then try and manipulate the elements within
    the frame using javascript ?

    Would that work ?

    Thanks & Regards
    Krishnan Mahadevan

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


    On Tue, Sep 4, 2012 at 12:11 PM, Pavithra wrote:

    Thanks Krishnan for the reference.

    Yesterday actually, I tried via javascript as below:
    ((JavascriptExecutor)
    driver).executeScript("self.parent.parent.parent.parent.window.focus()");

    Since, I was in iframe/html/body/div [I gave four parents so that it goes
    to iframe's parent and then focus] but still it didn't work. It doesn't
    throw any error.
    But, when I tried getting the element with xpath,/html/body/div I am still
    getting the element inside iframe and not the element outside iframe.

    From the api, I could understand that switchtodefaultcontent(); selects
    the main document when the page contains iframes. Here what does select
    mean? does it focus? What action, I need to do on the window (which I get
    via javascript) to come out of the frame ?

    Thanks,
    Pavithra

    --
    You received this message because you are subscribed to the Google Groups
    "webdriver" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/webdriver/-/vGROuCCCgJcJ.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to
    webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/webdriver?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Pavithra at Sep 5, 2012 at 8:59 am
    Krishnan,
    That's not bad idea. I can do that.
    But there are not just one scenario which I should inside frame. There are
    many like: clicking, typing, asserting, etc... I am not sure whether all
    these would be succeeded with javascript. But I can give a try!!

    Thanks,
    Pavithra

    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/W8oY4bGxw2wJ.
    To post to this group, send email to webdriver@googlegroups.com.
    To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
  • Milind at Sep 24, 2013 at 4:26 pm
    Hi Pavithra,
    I am facing the same issue with android-server-2.32.0.apk android 4.2.2,
    were you able to workaround with Javascript?

    Thanks,
    Milind
    On Wednesday, September 5, 2012 1:59:14 AM UTC-7, Pavithra wrote:

    Krishnan,
    That's not bad idea. I can do that.
    But there are not just one scenario which I should inside frame. There are
    many like: clicking, typing, asserting, etc... I am not sure whether all
    these would be succeeded with javascript. But I can give a try!!

    Thanks,
    Pavithra
    --
    You received this message because you are subscribed to the Google Groups "webdriver" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+unsubscribe@googlegroups.com.
    To post to this group, send email to webdriver@googlegroups.com.
    Visit this group at http://groups.google.com/group/webdriver.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupwebdriver @
categorieswatir
postedAug 31, '12 at 10:53a
activeSep 24, '13 at 4:26p
posts10
users4
websitewatir.com

People

Translate

site design / logo © 2021 Grokbase