Hi Marsha_R and AlexKaras ,
Thanks for your responses. Sorry I will add some more background details for a better understanding.
I earlier tried directly identifying the elements and performing the click option. It works fine but the performance was very bad as there were similar objects with huge data in the same page, so it was taking long time to find the element. So the workaround for this was that I find the element using the specific iFrame in which the element belongs. This has improved the performance as the scope of searching for element reduced.
Marsha_R Yes the 2nd element (MainTab) is still visible after I switch the frame.
AlexKaras and Marsha_R - I am not sure if the control switches to the iFrame when I find the element or it just looks within the specific frame without switching the control. Below is the detailed code flow I used to find the element in the iFrame named "iFrame_sr". After below code flow is when I'm trying to click on second element which is outside of iFrame scope.
//get the frame object in which element is present, using the name of the iFrame.
let frame = tcHelper.GetiFrameObject(this.getWebPage(),"iFrame_sr"); // refer below section for function body
//get the web element object by searching in the frame object received from the above code using the ID of the webelement
let webObj = tcHelper.GetWebObjectInFrameWithID(frame,webEleId); // refer below section for function body
//Args: webPageObj is the page in which iFrame is present. iframeID is the ID of the iframe being captured
GetiFrameObject(webPageObj,iframeID){
let iframe = webPageObj.contentDocument.getElementById(iframeID);
if(iframe==null)
Log.Error("Unable to find the iframe object with ID: "+iframeID+" in the webpage");
else
return iframe;
}
GetWebObjectInFrameWithID(frameObj,webElementID){
let webObj = frameObj.contentDocument.getElementById(webElementID);
if(webObj==null)
Log.Error("Unable to find the web object with ID: "+webElementID+" in the specified frame of the webpage");
else
return webObj;
}