Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
bhaskarvphani
Posts : 1
Join date : 2012-03-27

Switching between nested iframes within a frame Empty Switching between nested iframes within a frame

Sun Apr 01, 2012 3:06 am
Please help me in resolving the following issue.

Hierarchy of Frameset, frames and iframes in a single web page

Frameset id=”mainframeset”….
frame id=”usersession”…
Frameset id=”lowerframeset”..
Frame id=”Nav”
Frameset =”main pane”…
Frame id=”Work”…
Iframe1 :(each Iframe have attributes frameborder="0",allowtransparency="true",tabindex="0",src="",title="Rich text editor, work_135(only change is this id for each iframe), press ALT 0 for help.",style="width:100%;height:100%"
Iframe2: (each Iframe have attributes frameborder="0", allowtransparency="true",tabindex="0",src="",title="Rich text editor, work_140(only change is this id for each iframe), press ALT 0 for help.",style="width:100%;height:100%"
Iframe3:
Iframe4:

Code I have is :

driver.switchTo().defaultContent();
driver.switchTo().frame("work");
System.out.println(" Switched to Work ");
List Element = driver.findElements(By.xpath("//iframe"));
System.out.println("No of Iframes are :"+ Element.size());
System.out.println(driver.switchTo().frame(Element.get(0)));
driver.findElement(By.xpath("//*[@id='ck_article_title']")).click();
driver.findElement(By.xpath("//*[@id='ck_article_title']/p[1]")).sendKeys("Ifram 1 ");

System.out.println(driver.switchTo().frame(Element.get(1)));
driver.findElement(By.xpath("//*[@id='ck_article_standfirst']")).click();
driver.findElement(By.xpath("//*[@id='ck_article_standfirst']/p[1]")).sendKeys("I frame 2 ");

Error while running the above code:

Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: Element belongs to a different frame than the current one - switch to its containing frame to use it

Problem:

a) The above code enters the text in iframe 1 but gives above error when trying to identify iframe2 within frame "work"

Please help me to identify each iframes sequentially and enter required text in it.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum