Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created April 22, 2013 12:45
Show Gist options
  • Select an option

  • Save DinisCruz/5434627 to your computer and use it in GitHub Desktop.

Select an option

Save DinisCruz/5434627 to your computer and use it in GitHub Desktop.
var ie = "ie_xpHky".o2Cache<WatiN_IE>(()=> panel.clear().add_IE()).silent(true); // ie ramdon value for o2cache makes this object to unique amongst multiple instances of this control
ie.open("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe"); //Load test page
ie.waitForComplete(); // Wait for it to load the IFrames
var hostIFrames = ie.IE.Frames; // Get All frames from the tryhtml_iframe page (using the Frame property from the WatiN's IE object)
var hostIFrame = (Frame)hostIFrames.last(); // Get the right-hand-side IFrame
//this is a hacked way to change the frame's host width)
var hostHtml = hostIFrame.Html; // Gets the html which is the same as the text shown on the left-hand-side textbox
//return hostHtml;
var iFrameElement = (Element) hostIFrame.elements("IFRAME").first();
iFrameElement.outerHtml(iFrameElement.outerHtml().replace("<IFRAME ", "<IFRAME width='100%' "));
ie.waitForComplete();
//Here is how to click a link from inside the Hosted Frame
var iFrame = (Frame)hostIFrame.Frames.first();// Gets the inner frame (pointing to http://www.w3schools.com)
return iFrame.Links.toList()
.where((link)=>link.innerHtml()=="Learn ASP")
.first()
.scrollIntoView()
.select()
.flash()
.flash()
.click()
;
//using WatiN.Core
//O2Ref:Microsoft.mshtml.dll
//O2File:WatiN_IE_ExtensionMethods.cs
//O2Ref:WatiN.Core.1x.dll
//O2Tag_DontAddExtraO2Files;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment