1

Not able to switch on newly opened frame

Below are the firebug details for my opened frame

<html xmlns="http://www.w3.org/1999/xhtml" style="overflow: hidden; height: 100%; border: medium none; padding: 0px; margin: 0px;">
<head id="Head1">
<body class="ui-layout-container" tabindex="-1" onload="changeHashOnLoad();" style="overflow: hidden; width: auto; height: auto; margin: 0px; position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px;">
<form id="form1" action="Layout.aspx" method="post">
<div class="aspNetHidden">
<script type="text/javascript"> //<![CDATA[ var theForm = document.forms['form1']; if (!theForm) {     theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) {     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {         theForm.__EVENTTARGET.value = eventTarget;         theForm.__EVENTARGUMENT.value = eventArgument;         theForm.submit();     } } //]]> </script>
<script type="text/javascript" src="/WebResource.axd?d=fqV81KWLWhVg-lLAb4IT61Rf7nenS5CfBLW8eORCIqb7qWR5ebnXv0WLAGMAjel0UlUanbUozV0ld0Q4kzHM9PmUJF_BtBl1TXTKBUvGOWk1&t=635586541120000000"/>
<div class="aspNetHidden">
<div id="wrapper" class="ui-layout-pane ui-layout-pane-center ui-layout-container ui-layout-pane-hover ui-layout-pane-center-hover ui-layout-pane-open-hover ui-layout-pane-center-open-hover" style="display: block; position: absolute; margin: 0px; left: 0px; right: 0px; top: 0px; bottom: 32px; height: 213px; width: 1366px; z-index: 0; visibility: visible; overflow: hidden;">
<div id="header-wrapper" class="ui-layout-north ui-layout-pane ui-layout-pane-north" style="position: absolute; margin: 0px; top: 0px; bottom: auto; left: 0px; right: 0px; width: auto; z-index: 0; height: 75px; display: block; visibility: visible; overflow: visible;">
<div id="container" class="ui-layout-center window-tab ui-layout-pane ui-layout-pane-center ui-tabs ui-widget ui-widget-content ui-corner-all ui-layout-pane-hover ui-layout-pane-center-hover ui-layout-pane-open-hover ui-layout-pane-center-open-hover" style="position: absolute; margin: 0px; left: 0px; right: 0px; top: 83px; bottom: 7px; height: 123px; width: 1366px; z-index: 0; overflow: hidden; display: block; visibility: visible;">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist">
<li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tab-0" aria-labelledby="ui-id-1" aria-selected="false">
<li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active ui-state-hover ui-state-focus" role="tab" tabindex="0" aria-controls="tab-39" aria-labelledby="ui-id-2" aria-selected="true">
<a id="ui-id-2" class="ui-tabs-anchor" href="#tab-39" role="presentation" tabindex="-1">BOS Parameters</a>
<span id="spantab-39" class="ui-icon ui-icon-close" role="presentation">Remove Tab</span>
</li>
<li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tab-8" aria-labelledby="ui-id-3" aria-selected="false">
</ul>
<div id="divRightContent" class="ui-layout-content" style="border-left: 1px solid rgb(222, 222, 222); border-right: 1px solid rgb(222, 222, 222); float: left; position: relative; height: 0px; visibility: visible; display: none;">
<div id="AccessKeyPanel">
<iframe id="tab-39" class="ui-tabs-panel ui-widget-content ui-corner-bottom" width="100%" height="100%" frameborder="0" scrolling="auto" data-long-desc="Masters/BOSSetting.aspx?Rts=010000000010&css=icon-add-template&skey=&title=BOS%20Parameters&id=39&tname=BOS%20Options" src="Masters/BOSSetting.aspx?Rts=010000000010&css=icon-add-template&skey=&title=BOS%20Parameters&id=39&tname=BOS%20Options" style="display: block;" onload="showTab(this);" aria-labelledby="ui-id-2" role="tabpanel" aria-expanded="true" aria-hidden="false"/>
<iframe id="tab-8" class="ui-tabs-panel ui-widget-content ui-corner-bottom" width="100%" height="100%" frameborder="0" scrolling="auto" data-long-desc="Masters/Customer.aspx?Rts=111101000010&css=icon-add-template&skey=&title=Customers&id=8&tname=Customer" src="Masters/Customer.aspx?Rts=111101000010&css=icon-add-template&skey=&title=Customers&id=8&tname=Customer" style="display: none;" onload="showTab(this);" aria-labelledby="ui-id-3" role="tabpanel" aria-expanded="false" aria-hidden="true"/>
</div>
5
  • I have already used driver.switchTo().frame(1); or by frame name, Id Having issue only in IE it is working fine in firefox by using driver.switchTo().frame(1);
    – mH16
    May 20, 2015 at 11:44
  • stackoverflow.com/questions/7257381/…
    – FDM
    May 20, 2015 at 12:48
  • Voting to close this question, does not contain enough information and no response to the given answers. If you did resolve your issue please add more info or an answer :) Jun 20, 2015 at 16:49
  • please provide some more info like error list, Jan 18, 2016 at 10:02
  • i have one solution for you, first get all frame ids then switch driver.findelement(By.tag("iframe")) Feb 17, 2016 at 13:07

3 Answers 3

2

The solution I would use is the WebDriver's driver.switchTo().frame() method but avoiding the index number.

You can select the window you want using;

  1. A number. (0 based index normally but NOT always with IE)
  2. A name or ID.
  3. A previously found WebElement.

An example:

driver.switchTo().frame(driver.findElement(By.id("Head1")));
0
0

IE driver is sometime difficult(and frustrating) to make work when things are running properly on chrome and firefox. For your specific example, I have had issues with window order in the IE driver in the past. So the number of windows that you have open may not correspond to what window you actually are trying to access. You have to write your own handler for the window order, because you cannot rely on what the IE driver gives. Before I write an example for you, I just noticed the comment on your original post that has an awesome code sample. FDM gives a great example with his comment on your original post, JimEvans wrote an example script in his post on stackoverflow that may help you in this situation.

0

Have you checked to see if it's a possible timing issue?

Seems dumb but response times between browsers can sometimes give odd results like this.

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