Webdriver not able to navigate into new web window (iframe) | Selenium Forum
M
Posted on 10/06/2016
Hi,
language: Java, IDE: IntelliJ, Browser: Chrome

Issue: After clicking a button on a web page, a [b:3l3rzoah]new [/b:3l3rzoah]web page opens up and not able to find the element in new web page

Totally two frames exists on web page

Tried "Switching" to two different frames and try'g to find the element but no luck...tried all sorts of different solutions available online.
Attaching the HTLM file (last line in the HTML is the one i'm trying to "SendKeys" )

First time ever I'm posting a question - please do let me know if any more information is required

Cannot attach the HTML file so pasting here:

<html style="">
<head>
<frameset border="0" frameborder="0" framespacing="0" cols="250" rows="165,*">
<frame id="searchFrame" framespacing="0" marginheight="0" marginwidth="0" noresize="" scrolling="Auto" frameborder="0" name="searchFrame" src="/_ui/common/data/LookupSearchFrame?lkfm=editPage&lksrch=&lkent=a11&lktp=a0c&lknm=CF00NU0000003CexU&lkfield=00NU0000003CexU" title="Search">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html style="">
<head>
<body class="hasMotif lookupTab LookupSearchFrame brandNoBgrImg" onfocus="if(this.bodyOnFocus)bodyOnFocus();" onload="if(this.bodyOnLoad)bodyOnLoad();" onbeforeunload="if(this.bodyOnBeforeUnload){var s=bodyOnBeforeUnload();if(s)return s;}" onunload="if(this.bodyOnUnload)bodyOnUnload();">
<form id="theForm" target="resultsFrame" onsubmit="if (window.ffInAlert) { return false; }" name="theForm" method="GET" action="/_ui/common/data/LookupResultsFrame">
<input id="lkent" type="hidden" value="a11" name="lkent">
<input id="lkfield" type="hidden" value="00NU0000003CexU" name="lkfield">
<input id="lkfm" type="hidden" value="editPage" name="lkfm">
<input id="lknm" type="hidden" value="CF00NU0000003CexU" name="lknm">
<input id="lktp" type="hidden" value="a0c" name="lktp">
<div class="lookup">
<div class="bPageTitle">
<div class="pBody">
<div id="msgBox" class="message infoM4">
<script>
<label class="assistiveText" for="lksrch">Search</label>
<input id="lksrch" type="text" value="" size="20" placeholder="Search..." name="lksrch" maxlength="80">

M
Replied on 12/06/2016

how are you switching. send the code.


M
Replied on 17/06/2016

Finding number of frames, returns = 2

int size = SF.findElements(By.tagName("iframe")).size();
System.out.println("Total frames present - " + size);

then trying to click the element assuming in frames either 1 or 2


System.out.println("Clicked on bulb"); //after clicking this element then opens up a new browser - problem starts here

Thread.sleep(7000);

SF.switchTo().frame(1);

SF.findElement(By.xpath("//input[@id= 'lksrch']")).sendKeys("chehalis"); // FAILS to find the element embedded inside the frame

Tried by inputting frame numbers in different combo's 0,1 and 2 and none of them is successful

Webdriver returns an error "No such frame"


M
Replied on 17/06/2016

you have switch to frame 1 and then switch to default frame and then switch to frame 2.


M
Replied on 28/09/2016

Hi Ashish,

Due to some project delays, i kept my selenium project in limbo and now again, it's time to get the hands dirty.

For above question, tried different solutions with switching windows but couldn't able to manage to make webdriver to [b:2b892ata]move[/b:2b892ata] to new window.

Would you mind have another look if you have time ?


M
Replied on 28/09/2016

Update:

Good news is I can switch to the new window opened. ( confirmed by maximizing the new window)

Bad news is [b:1njr172v]I cannot find any element in the new window[/b:1njr172v] - I made sure my xpath is correct and no spelling mistakes ( also used wait statements to ensure webdriver has enough time to find out the element)

help ?