In most of the GUI applications, you might have not come across with Frames/iFrames mostly but if you are using PEGA applications then definitely you might come across with Frames/iFrames that too more than one frame without no doubt.
The challenge part here is you may be seeing the same object in more than one Frame. This is the situation where automation developer has to break once brain to automate such weird behavior of the application, I mean the complexity of the PEGA application will be like that.
Using Selenium, when Frame/iFrames appears you have to switch to Frame first, then only the specific Object on the desired page will be identified, so that you can action on the Object later on.
Now, you will learn or get to know more in terms of Selenium code here below.
How to ensure there is a Frame/iFrame present in a web page:
Steps to ensure:
1. Click F12/Go to Developer Tools section
2. In Browser, select Ctrl+F, then find for "//iframe
3. Then you will see number of "iframes" present in the page
How to navigate to Frame/iFrame present in a web page:
Ways to switch Frame are:
1. By Index
2. By Frame Name or ID
Other information/operations on Frames
1. Handling dynamic Frame
2. Handing Child Frame (Multiple Frames)
3. Move back to Parent Frame
4. Move back to Most Parent Frame
By Index:
Examples:
driver.switchTo.frame(0); //switch to index 0
driver.switchTo.frame(1); //switch to index 1
driver.switchTo.frame(2); //switch to index 2
By Frame Name:
Examples:
driver.switchTo.frame("Frame1");
driver.switchTo.frame("Frame2");
driver.switchTo.frame("Frame3");
By Frame ID:
Examples:
driver.switchTo.frame("Frame123CV_0A");
driver.switchTo.frame("Frame123CV_1A");
driver.switchTo.frame("Frame123CV_2A");
Move back to Parent Frame
Move back to Most Parent Frame
The challenge part here is you may be seeing the same object in more than one Frame. This is the situation where automation developer has to break once brain to automate such weird behavior of the application, I mean the complexity of the PEGA application will be like that.
Using Selenium, when Frame/iFrames appears you have to switch to Frame first, then only the specific Object on the desired page will be identified, so that you can action on the Object later on.
Now, you will learn or get to know more in terms of Selenium code here below.
How to ensure there is a Frame/iFrame present in a web page:
Steps to ensure:
1. Click F12/Go to Developer Tools section
2. In Browser, select Ctrl+F, then find for "//iframe
3. Then you will see number of "iframes" present in the page
How to navigate to Frame/iFrame present in a web page:
Ways to switch Frame are:
1. By Index
2. By Frame Name or ID
Other information/operations on Frames
1. Handling dynamic Frame
2. Handing Child Frame (Multiple Frames)
3. Move back to Parent Frame
4. Move back to Most Parent Frame
By Index:
Examples:
driver.switchTo.frame(0); //switch to index 0
driver.switchTo.frame(1); //switch to index 1
driver.switchTo.frame(2); //switch to index 2
By Frame Name:
Examples:
driver.switchTo.frame("Frame1");
driver.switchTo.frame("Frame2");
driver.switchTo.frame("Frame3");
By Frame ID:
Examples:
driver.switchTo.frame("Frame123CV_0A");
driver.switchTo.frame("Frame123CV_1A");
driver.switchTo.frame("Frame123CV_2A");
Handling dynamic Frame:
Follow the below steps:
1. Get the total no. of Frames present in the particular web page
2. Validate your desired Object present in that web page, repeat the loop until last
3. Later, find the Frame name or Index in which the desired Object present
4. Finally, after obtaining the Frame no., switch to Frame and perform the action.
Example (Steps 1,2 & 3): To get the Frame No of the specific Object
WebElement element=driver.findElement(By.name("userName"));
int size = driver.findElements(By.tagName("iframe")).size();
for (i=0;i<size; i++){
driver.switchTo().parentFrame();
driver.switchTo().frame(i);
driver.switchTo().parentFrame();
driver.switchTo().frame(i);
try{
if (element.isDisplayed())
break;
}
catch(Exception e)
{
e.fillInStackTrace();
}
return i;
}
Example (Step 4): Lets say above Example returned value in frameNo argument and perform the action on the Object.
driver.switchTo().parentFrame();
driver.switchTo().frame(frameNo);
return element.sendKeys("Vasu Chiluveru"); //action on the Web Element
Handling Child Frame (Multiple Frames)
Example:
driver.switchTo().frame("ParentFrameName").switchTo().frame("ChildFrameName");
Move back to Parent Frame
If you want to Move back to the parent frame use below code
driver.switchTo().parentFrame();
Move back to Most Parent Frame
If you want to Move back to most parent frame use below code
driver.switchTo().defaultContent();
Great Post with valuable information.I am glad that I have visited this site.Share more updates.
ReplyDeleteselenium training in OMR
selenium training in anna nagar
Java Training in OMR
Java course in Tambaram
DevOps Training in Anna Nagar
Digital Marketing Course in Anna Nagar
Software Testing Training in T Nagar
Graphic design courses in Porur
Web Designing Course in T Nagar
PHP Training in Chennai
Nice article you have posted here.Thank you for sharing this information. Share more like this.
ReplyDeleteselenium training in tambaram
selenium training in Chennai
Software Testing Training in OMR
RPA Training in Anna Nagar
Web Designing Course in Porur
PHP Training in T Nagar
Dot Net Training in T Nagar
Python Training in Tambaram
Android Training in Anna Nagar
Spoken English Classes in Anna Nagar
Thanks for sharing a valuable blog. keep sharing.
ReplyDeletebest way to learn java programming
cross platform desktop app development
social marketing campaigns examples
which is the best cloud service
tableau admin interview questions
I think this is the best article today. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic. Keep sharing your information regularly for my future reference.Excellent blog admin. This is what I have looked. Check out the following links for QA services
ReplyDeleteTest automation software
Best automated testing software
Mobile app testing services
Thanks again for the article post.Really thank you! Fantastic.
ReplyDeleteMulesoft training
python training
angular js training
selenium trainings