On my project i had to face with some elements which is inside a iframe.
So the steps are;
So the steps are;
- Click on a link (Which opens the iFrame).
- Locate some elements inside the iFrame.
- Close the iFrame by the close button on the iFrame.
Opening the iframe is Okey, Not a big deal.
This is my Iframe.
Issue happens when locating some elements on it.
I tried with several methods, But nothing works.
Finally i found that i have to switch to the iFrame 1st.
IWebElement detailFrame = elm.Iframe;
Driver.SwitchTo().Frame(detailFrame);
Then closing the iFrame.
I tried with pressing the escape key. -But NO luck.
Actions action = new Actions(Driver);
action.SendKeys(OpenQA.Selenium.Keys.Escape).Build().Perform();
Then tryed on clicking on some other area out of the iFrame.
and it works.
But before that i has to switch back to the default frame.
Actions action = new Actions(Driver);
Driver.SwitchTo().DefaultContent();
action.Click(elm.Summary).Build().Perform();
And im Done.
If u do the selenium assignment given to us by u... U will find this scenario... Grrrrr
ReplyDeleteIn my case im having a headless iframe.where it dont have close,minimize or maximize buttons.
DeleteLoL
ReplyDelete