Reputation: 1
![Child frames are having dynamic name/id][1]
Browser-IE8
I have to find a prompt box inside the second child iframe.
the parent iframe is having fixed id.Able to find element inside that
using driver.switchTo().frame(0)
The first child iframe is having dynamic name/id.
cframe_ms_id59
.Only last part changes.i.e. id59
I am able to find this element using xpath
driver.findElement(By.xpath("//iframe[contains(@id, 'cframe_ms']"))
But my prompt box having a textbox resides in the Second Child iframe (green color )****having dynamic name/id.**I am not able to enter inside this iframe and not able to find any element inside that.
Plz suggest some solution
Here is the HTML code structure-
<html>
<head>
<body>
<iframe id="adviseDesktop" src="...//path">**//Parent Iframe-Able to
| find this iframe using driver.switchto().frame(0)**
|------ <html>
<head>
<body class="desktopbody" id="desktop body">
| ------code----
| ------------code---
|------------ <iframe name="cframe_ms_id59" id="cframe_ms_id59" src='abc.jsp">**//first child iframe last part of name and id changing dynamically**
| -------------
| ------------
|------------- <table class="mdiwindow" id =dwindow_ms_99"
| <tr height="100%">
|--- <td class="mdiwindowContent">
|-- <iframe name="cframe_ms_id54" id="cframe_ms_id54" src="/xysx/modal/desktop/main.jspx">**//Second child iframe last part of name and id changing dynamically.IFrame where our text box of prompt box resides** |
|------------
| -----------------
|----- <input name=balance_val class="x27" id="balance_val>**//textbox**
Upvotes: 0
Views: 1402
Reputation: 106
Looking at the HTML, you seem to have an iframe inside an iframe inside an iframe which contains the input you want to find. For this you need to switch into frames sequentially. See below for C# code.
var textbox = driver.SwitchTo()
.Frame("adviseDesktop") //control in frame with id="adviseDesktop"
.SwitchTo()
.Frame(1) //control in frame with id="cframe_ms_id54"
.FindElement(By.Id("balance_val")); //input with id="balance_val"
Once you are done with the actions in that frame, you need to switch out to default content.
//control in frame with id="cframe_ms_id54"
_driver.SwitchTo()
.ParentFrame() //control in frame with id="adviseDesktop"
.SwitchTo()
.DefaultContent(); //control in topmost body of the document
Upvotes: 0
Reputation: 76
i think it's usefull for you. get xpath from child frame before type this code line -
driver.switchTo().frame(1);
than you switch to child frame so you get easily xpath or class/id of child frame elements.
back to default frame type this code line -
driver.switchTo().defaultContent();
where is your attached screenshot ??
Upvotes: 1