public abstract class AuthenticatedPage : Page { protected ElementScope TopMenu; protected ElementScope LeftMenu; protected ElementScope MainContent; protected AuthenticatedPage(BrowserSession browserSession) : base(browserSession) { TopMenu = browserSession.FindFrame("1_mainMenuFrame"); LeftMenu = browserSession.FindFrame("1_menuFrame"); MainContent = browserSession.FindFrame("1_displayFrame"); }
TopMenu.ClickLink("Log off");
I know that what I am doing is a special case and that anyone in there right mind wouldn't be using frames but its not something I can change. Am I misusing coypu? can you think of a better way of using it? If not would you consider changing locator into a class which would allow option parameters which could say this is an id and a frame? or perhaps a FindFrameId and FindFrameId. Please let me know your thoughts.
Thanks
Adam
Hey Adrian,
I'm afraid its me again. I have updated to the latest version of Coypu from the version without scope ( I gave up when I tried before). This has slowed down tests because Iuse frames. My site contains a page with 3 frames, a top menu and a left menu. So heres what I have had to do to get it to work. In my base class I have:public abstract class AuthenticatedPage : Page { protected ElementScope TopMenu; protected ElementScope LeftMenu; protected ElementScope MainContent; protected AuthenticatedPage(BrowserSession browserSession) : base(browserSession) { TopMenu = browserSession.FindFrame("1_mainMenuFrame"); LeftMenu = browserSession.FindFrame("1_menuFrame"); MainContent = browserSession.FindFrame("1_displayFrame"); }
When I want to reference a link on the topmenu I use:TopMenu.ClickLink("Log off");
Every interaction now needs to be prefixed with TopMenu. MainContent. , etc. So this sounds ok until you look at what selenium is doing. Everytime I run a command it does something like:
- Is there an iframe with the id topMenu?
- Is there an iframe with the name topMenu?
- Is there an iframe with the title topMenu?
- Is there an frame with the id topMenu? <-- my code exits at this point but it could continue if I used title
- Is there an frame with the name topMenu?
- Is there an frame with the title topMenu?
- Click the link
I know that what I am doing is a special case and that anyone in there right mind wouldn't be using frames but its not something I can change. Am I misusing coypu?
can you think of a better way of using it? If not would you consider changing locator into a class which would allow option parameters which could say this is an id and a frame? or perhaps a FindFrameId and FindFrameId. Please let me know your thoughts.
Thanks
Adam
protected internal ElementFound FindElement() { if (element == null || element.Stale) { element = elementFinder.Find(); var selenium = ((OpenQA.Selenium.Remote.RemoteWebDriver)element.Native); try { selenium.FindElementById("inputInIFrame"); } catch { // hit me if not the iframe } var areWeStale = element.Stale; } return element; }
This meant that when the element was a seleniumIframe areWeStale was always true. Please let me know if this is correct behavior or perhaps the cause of the bug.
Regards
Adam