[Watin-commits] SF.net SVN: watin:[1195] trunk
Brought to you by:
jvmenen
From: <jv...@us...> - 2011-04-12 09:00:01
|
Revision: 1195 http://watin.svn.sourceforge.net/watin/?rev=1195&view=rev Author: jvmenen Date: 2011-04-12 08:59:53 +0000 (Tue, 12 Apr 2011) Log Message: ----------- * Added ReturnDialogHandler.CreateInstance() which will return the correct version for your version of IE. * Added Frame.FrameElement which will return the frame element in which a frame or iframe is contained. * Fixed issue with "NoMerge". Now will work for IE8 and IE9. * Refactored AllFramesProcessor to work (better) with IE9. Fixes issues with iterating over Frames in FrameCollection sometimes resulting in unpredictable crashes. * Fixed issue were Find.BySelectore was not working for elements in a Frame. Partially fixed. Doesn't work yet for nested frames pages. * fixed issue with selecting item in selectlist or selecting a checkbox when using IE9. Now using the new Expando class to get the value of a property from a DOM element. * AlertDialogHandlerTests contains some spikes to handle alert dialog browser agnostic * Added test to make sure every html file has the meta tag http-equiv="X-UA-Compatible" * http-equiv="X-UA-Compatible" content is set to "edge". This will always run the tests with latest IE mode (with IE9 in IE9 mode, with IE8 in IE8mode etc...). Modified Paths: -------------- trunk/src/Core/Core.csproj trunk/src/Core/DialogHandlers/ReturnDialogHandler.cs trunk/src/Core/Frame.cs trunk/src/Core/IE.cs trunk/src/Core/Native/InternetExplorer/AllFramesProcessor.cs trunk/src/Core/Native/InternetExplorer/IEDocument.cs trunk/src/Core/Native/InternetExplorer/IEElement.cs trunk/src/Core/Native/InternetExplorer/IEElementCollection.cs trunk/src/Core/Native/InternetExplorer/IEUtils.cs trunk/src/Core/Native/InternetExplorer/JScriptElementArrayEnumerator.cs trunk/src/Core/Native/Windows/Window.cs trunk/src/UnitTests/AttributeConstraintTests/FindBySelectorTests.cs trunk/src/UnitTests/AttributeConstraintTests/ProximityTests.cs trunk/src/UnitTests/ButtonTests.cs trunk/src/UnitTests/CheckBoxTests.cs trunk/src/UnitTests/DialogHandlerTests/AlertDialogHandlerTests.cs trunk/src/UnitTests/DialogHandlerTests/ReturnJavaDialogHandlerTest.cs trunk/src/UnitTests/DocumentTests.cs trunk/src/UnitTests/ElementTests.cs trunk/src/UnitTests/FrameCrossDomainTests.cs trunk/src/UnitTests/FramesetWithinFrameSetTests.cs trunk/src/UnitTests/IFramesTests.cs trunk/src/UnitTests/Native/FireFoxTests/FireEventTests.cs trunk/src/UnitTests/SelectListTests.cs trunk/src/UnitTests/TestUtils/BaseWatiNTest.cs trunk/src/UnitTests/TextFieldTests.cs trunk/src/UnitTests/UnitTests.csproj trunk/src/UnitTests/WatiNSanityTests.cs trunk/src/UnitTests/html/BodyNotExistsBug.htm trunk/src/UnitTests/html/ButtonTests.html trunk/src/UnitTests/html/ClassConstraintTests.html trunk/src/UnitTests/html/CrossDomainFrameset.html trunk/src/UnitTests/html/Frameset.html trunk/src/UnitTests/html/FramesetWithinFrameset.html trunk/src/UnitTests/html/Index.html trunk/src/UnitTests/html/ListTests.html trunk/src/UnitTests/html/OnBeforeUnloadJavaDialog.html trunk/src/UnitTests/html/ProximityTests.html trunk/src/UnitTests/html/Tables.html trunk/src/UnitTests/html/TestEvents.html trunk/src/UnitTests/html/formsubmit.html trunk/src/UnitTests/html/html_with_object_tag.html trunk/src/UnitTests/html/iframes/leftpage.html trunk/src/UnitTests/html/iframes/main.html trunk/src/UnitTests/html/iframes/middlepage.html trunk/src/UnitTests/html/iframes/rightpage.html trunk/src/UnitTests/html/images.html trunk/src/UnitTests/html/intro.html trunk/src/UnitTests/html/main.html trunk/src/UnitTests/html/openNewWindow.html trunk/src/UnitTests/html/openNewWindowTarget.html trunk/src/UnitTests/html/popup.html trunk/src/UnitTests/html/styletests/Style.html trunk/src/UnitTests/html/theApp.html Added Paths: ----------- trunk/src/Core/Native/InternetExplorer/Expando.cs trunk/src/UnitTests/html/Frameset2.html trunk/src/UnitTests/html/iframes/FramesetWithinIFrame.html trunk/src/UnitTests/html/iframes/iFramesWithinFrameset.html Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Modified: svn:ignore - .MySCMServerInfo bin obj *.resharperoptions _ReSharper.* *.user *.suo build + .MySCMServerInfo bin obj *.resharperoptions _ReSharper.* *.user *.suo build nuget Modified: trunk/src/Core/Core.csproj =================================================================== --- trunk/src/Core/Core.csproj 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Core.csproj 2011-04-12 08:59:53 UTC (rev 1195) @@ -160,7 +160,7 @@ <Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.mshtml"> <HintPath>..\..\lib\Net\3.5\Microsoft.mshtml.dll</HintPath> - <EmbedInteropTypes>True</EmbedInteropTypes> + <EmbedInteropTypes>False</EmbedInteropTypes> </Reference> <Reference Include="System"> <Name>System</Name> @@ -243,6 +243,7 @@ <Compile Include="Native\Chrome\ChromeException.cs" /> <Compile Include="Native\IClientPort.cs" /> <Compile Include="Native\ClientPortBase.cs" /> + <Compile Include="Native\InternetExplorer\Expando.cs" /> <Compile Include="Native\InternetExplorer\IEFireEventHandler.cs" /> <Compile Include="Native\InternetExplorer\JScriptElementArrayEnumerator.cs" /> <Compile Include="Native\JavaScriptEngineType.cs" /> Modified: trunk/src/Core/DialogHandlers/ReturnDialogHandler.cs =================================================================== --- trunk/src/Core/DialogHandlers/ReturnDialogHandler.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/DialogHandlers/ReturnDialogHandler.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -16,11 +16,16 @@ #endregion Copyright +using System; +using System.Threading; +using WatiN.Core.Exceptions; +using WatiN.Core.Interfaces; using WatiN.Core.Native.Windows; +using WatiN.Core.UtilityClasses; namespace WatiN.Core.DialogHandlers { - public class ReturnDialogHandler : ConfirmDialogHandler + public class ReturnDialogHandler : ConfirmDialogHandler, IReturnDialogHandler { /// <summary> /// Determines whether this instance can handle the specified window by checking <see cref="Window.StyleInHex"/>. @@ -34,5 +39,106 @@ { return (window.StyleInHex == "94C803C5" && ButtonWithId1Exists(window.Hwnd)); } + + public static IReturnDialogHandler CreateInstance() + { + var ieVersion = IE.GetMajorIEVersion(); + + return ieVersion < 9 ? (IReturnDialogHandler) new ReturnDialogHandler() : new ReturnDialogHandlerIe9(); + } } + + public interface IReturnDialogHandler : IDialogHandler + { + WinButton CancelButton { get; } + WinButton OKButton { get; } + void WaitUntilExists(int waitDurationInSeconds); + bool Exists(); + void WaitUntilExists(); + } + + public class ReturnDialogHandlerIe9 : BaseDialogHandler, IReturnDialogHandler + { + private Window _window; + + public WinButton CancelButton + { + get + { + var hwnd = GetChildWindowHwnd(_window.Hwnd, "5000200E"); + return hwnd != IntPtr.Zero ? new WinButton(hwnd) : null; + } + } + + public WinButton OKButton + { + get + { + var hwnd = GetChildWindowHwnd(_window.Hwnd, "5000200F"); + return hwnd != IntPtr.Zero ? new WinButton(hwnd) : null; + } + } + + public override bool HandleDialog(Window window) + { + if (CanHandleDialog(window)) + { + _window = window; + + while (window.Exists()) + { + Thread.Sleep(200); + } + return true; + } + return false; + } + + public override bool CanHandleDialog(Window window) + { + return (window.StyleInHex == "96C00284"); + } + + public void WaitUntilExists(int waitDurationInSeconds) + { + var tryActionUntilTimeOut = new TryFuncUntilTimeOut(TimeSpan.FromSeconds(waitDurationInSeconds)); + tryActionUntilTimeOut.Try(Exists); + + if (!Exists()) + { + throw new WatiNException(string.Format("Dialog not available within {0} seconds.", waitDurationInSeconds)); + } + } + + public bool Exists() + { + return _window != null && _window.Exists(); + } + + private IntPtr GetChildWindowHwnd(IntPtr parentHwnd, string styleInHex) + { + var hWnd = IntPtr.Zero; + NativeMethods.EnumChildWindows(parentHwnd, (childHwnd, lParam) => + { + var window = new Window(childHwnd); +// Console.WriteLine("childhwnd: " + childHwnd); +// Console.WriteLine("childhwnd.styleinhex: " + window.StyleInHex); + if (window.StyleInHex == styleInHex) + { + hWnd = childHwnd; + return false; + } + + return true; + }, IntPtr.Zero); + + return hWnd; + } + + public void WaitUntilExists() + { + WaitUntilExists(30); + } + } + } \ No newline at end of file Modified: trunk/src/Core/Frame.cs =================================================================== --- trunk/src/Core/Frame.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Frame.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -28,8 +28,8 @@ [ElementTag("iframe", Index = 1)] public class Frame : Document { - private readonly Element _frameElement; - private readonly INativeDocument _frameDocument; + public Element FrameElement { get; private set; } + private readonly INativeDocument _frameDocument; /// <summary> /// This constructor will mainly be used by the constructor of FrameCollection @@ -44,7 +44,7 @@ throw new ArgumentNullException("frameDocument"); _frameDocument = frameDocument; - _frameElement = new Element(domContainer, frameDocument.ContainingFrameElement); + FrameElement = new Element(domContainer, frameDocument.ContainingFrameElement); } /// <inheritdoc /> @@ -75,13 +75,13 @@ return Url; default: - return _frameElement.GetAttributeValue(attributeName); + return FrameElement.GetAttributeValue(attributeName); } } public virtual void SetAttributeValue(string attributeName, string value) { - _frameElement.SetAttributeValue(attributeName, value); + FrameElement.SetAttributeValue(attributeName, value); } } Modified: trunk/src/Core/IE.cs =================================================================== --- trunk/src/Core/IE.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/IE.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -543,7 +543,7 @@ { var arguments = "about:blank"; - if (GetMajorIEVersion() == 8 && Settings.MakeNewIe8InstanceNoMerge) + if (GetMajorIEVersion() >= 8 && Settings.MakeNewIe8InstanceNoMerge) arguments = "-nomerge " + arguments; var m_Proc = Process.Start("IExplore.exe", arguments); Modified: trunk/src/Core/Native/InternetExplorer/AllFramesProcessor.cs =================================================================== --- trunk/src/Core/Native/InternetExplorer/AllFramesProcessor.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Native/InternetExplorer/AllFramesProcessor.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -27,54 +27,53 @@ { public List<INativeDocument> Elements { get; private set; } - private readonly HTMLDocument htmlDocument; - private readonly IHTMLElementCollection frameElements; - private int index; + private readonly HTMLDocument _htmlDocument; + private readonly IHTMLElementCollection _iFrameElements; + private int _index; public AllFramesProcessor(HTMLDocument htmlDocument) { Elements = new List<INativeDocument>(); + _htmlDocument = htmlDocument; - frameElements = (IHTMLElementCollection) htmlDocument.all.tags("frame"); - - // If the current document doesn't contain FRAME elements, it then - // might contain IFRAME elements. - if (frameElements.length == 0) - { - frameElements = (IHTMLElementCollection)htmlDocument.all.tags("iframe"); - } - - this.htmlDocument = htmlDocument; + _iFrameElements = (IHTMLElementCollection)htmlDocument.all.tags("iframe"); } public HTMLDocument HTMLDocument() { - return htmlDocument; + return _htmlDocument; } public void Process(IWebBrowser2 webBrowser2) { - // Get the frame element from the parent document - var uniqueId = RetrieveUniqueIdOfFrameElement(); + var htmlDocument2 = (IHTMLDocument2)webBrowser2.Document; + var containingFrameElement = GetContainingFrameElement(); + Elements.Add(new IEDocument(htmlDocument2, containingFrameElement)); - var frameElement = RetrieveSameFrameFromHtmlDocument(uniqueId); - var nativeFrameElement = new IEElement(frameElement); - Elements.Add(new IEDocument((IHTMLDocument2) webBrowser2.Document, nativeFrameElement)); + _index++; + } - index++; + public IEElement GetContainingFrameElement() + { + var uniqueId = RetrieveUniqueIdOfFrameElement(); + var frameElement = RetrieveSameFrameFromHtmlDocument(uniqueId); + return new IEElement(frameElement); } private string RetrieveUniqueIdOfFrameElement() { - var element = (IHTMLElement) frameElements.item(index, null); - return ((DispHTMLBaseElement)element).uniqueID; + var frame = _iFrameElements.length == 0 ? + FrameByIndexProcessor.GetFrameFromHTMLDocument(_index, _htmlDocument) : + _iFrameElements.item(_index, null); + + return new Expando(frame).GetValue<string>("uniqueID"); } // This is lookup in htmldocument is needed to bridge between // two different "memory" representations of document and its frame elements. private IHTMLElement2 RetrieveSameFrameFromHtmlDocument(string frameElementUniqueId) { - var frame = htmlDocument.getElementById(frameElementUniqueId) as IHTMLElement2; + var frame = _htmlDocument.getElementById(frameElementUniqueId) as IHTMLElement2; if (frame == null) { throw new WatiNException("Couldn't find Frame or IFrame."); Added: trunk/src/Core/Native/InternetExplorer/Expando.cs =================================================================== --- trunk/src/Core/Native/InternetExplorer/Expando.cs (rev 0) +++ trunk/src/Core/Native/InternetExplorer/Expando.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -0,0 +1,59 @@ +#region WatiN Copyright (C) 2006-2011 Jeroen van Menen + +//Copyright 2006-2011 Jeroen van Menen +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion Copyright + +using System.Reflection; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Expando; + +namespace WatiN.Core.Native.InternetExplorer +{ + public class Expando + { + public object Object { get; private set; } + public IExpando AsExpando { get; private set; } + + public Expando(object expando) + { + Object = expando; + AsExpando = (IExpando) expando; + } + + public T GetValue<T>(string propertyName) + { + return (T)GetValue(propertyName); + } + + public object GetValue(string propertyName) + { + var property = AsExpando.GetProperty(propertyName, BindingFlags.Default); + if (property != null) + { + try + { + return property.GetValue(Object, null); + } + catch (COMException) + { + return null; + } + } + + return null; + } + } +} \ No newline at end of file Modified: trunk/src/Core/Native/InternetExplorer/IEDocument.cs =================================================================== --- trunk/src/Core/Native/InternetExplorer/IEDocument.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Native/InternetExplorer/IEDocument.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -57,13 +57,16 @@ /// <inheritdoc /> public INativeElementCollection AllElements { - get { return new IEElementCollection(htmlDocument.all, null); } + get { return new IEElementCollection(htmlDocument.all, (IEElement) ContainingFrameElement); } } /// <inheritdoc /> public INativeElement ContainingFrameElement { - get { return containingFrameElement; } + get + { + return containingFrameElement; + } } public INativeElement Body @@ -112,22 +115,7 @@ public string GetPropertyValue(string propertyName) { - var domDocumentExpando = (IExpando)htmlDocument; - - var property = domDocumentExpando.GetProperty(propertyName, BindingFlags.Default); - if (property != null) - { - try - { - return (string)property.GetValue(domDocumentExpando, null); - } - catch (COMException) - { - return null; - } - } - - return null; + return new Expando(htmlDocument).GetValue<string>(propertyName); } /// <inheritdoc /> Modified: trunk/src/Core/Native/InternetExplorer/IEElement.cs =================================================================== --- trunk/src/Core/Native/InternetExplorer/IEElement.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Native/InternetExplorer/IEElement.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -194,7 +194,10 @@ object attributeValue; try { - attributeValue = GetWithFailOver(() => AsHtmlElement.getAttribute(attributeName, 0)); + if (JSElement.UsePropertyInsteadOfAttribute.Contains(attributeName)) + attributeValue = GetWithFailOver(() => new Expando(AsHtmlElement).GetValue(attributeName)); + else + attributeValue = GetWithFailOver(() => AsHtmlElement.getAttribute(attributeName, 0)); } catch { @@ -211,7 +214,13 @@ return null; } - return attributeValue.ToString(); + var value = attributeValue.ToString(); + + if (attributeName.ToLowerInvariant() == "selected") + if (value.ToLowerInvariant() == "selected") + value = "True"; + + return value; } private static T GetWithFailOver<T>(DoFunc<T> func) @@ -409,7 +418,7 @@ if (AsHtmlElement.sourceIndex < 0) return false; // Note: We exclude elements that might appear as root elements from this check since we cannot verify them. - const string excludedTags = "! HTML HEAD BODY TITLE BASE LINK META SCRIPT STYLE"; + const string excludedTags = "! HTML HEAD BODY TITLE BASE LINK META SCRIPT STYLE FRAMESET"; if (excludedTags.Contains(TagName)) return true; return AsHtmlElement.offsetParent != null; Modified: trunk/src/Core/Native/InternetExplorer/IEElementCollection.cs =================================================================== --- trunk/src/Core/Native/InternetExplorer/IEElementCollection.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Native/InternetExplorer/IEElementCollection.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -84,10 +84,13 @@ public IEnumerable<INativeElement> GetElementsWithQuerySelector(string selector, DomContainer domContainer) { domContainer.RunScript(new ScriptLoader().GetSizzleInstallScript()); - var container = "document"; if (_element != null) + { container = _element.GetJavaScriptElementReference(); + if (new ElementTag(_element.TagName).Equals(new ElementTag("frame"))) + container = container + ".contentDocument"; + } var code = string.Format("document.___WATINRESULT = Sizzle('{0}', {1});", selector, container); domContainer.RunScript(code); Modified: trunk/src/Core/Native/InternetExplorer/IEUtils.cs =================================================================== --- trunk/src/Core/Native/InternetExplorer/IEUtils.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Native/InternetExplorer/IEUtils.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -22,6 +22,7 @@ using mshtml; using SHDocVw; using WatiN.Core.Exceptions; +using WatiN.Core.Logging; using WatiN.Core.Native.Windows; using WatiN.Core.UtilityClasses; using IEnumUnknown=WatiN.Core.Native.Windows.IEnumUnknown; @@ -65,6 +66,7 @@ { try { + Logger.LogDebug("[script] {0}", scriptCode); window.execScript(scriptCode, language); } catch (Exception ex) Modified: trunk/src/Core/Native/InternetExplorer/JScriptElementArrayEnumerator.cs =================================================================== --- trunk/src/Core/Native/InternetExplorer/JScriptElementArrayEnumerator.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Native/InternetExplorer/JScriptElementArrayEnumerator.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -18,9 +18,6 @@ using System.Collections; using System.Collections.Generic; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.Expando; using mshtml; namespace WatiN.Core.Native.InternetExplorer @@ -38,14 +35,15 @@ public IEnumerator<INativeElement> GetEnumerator() { - var result = GetPropertyValue(_fieldName, _ieDocument.HtmlDocument); + var result = new Expando(_ieDocument.HtmlDocument).GetValue(_fieldName); if (result == null) yield break; - var length = (int) GetPropertyValue("length", result); + var resultAsExpando = new Expando(result); + var length = resultAsExpando.GetValue<int>("length"); for (var i = 0; i < length; i++) { - var element1 = GetPropertyValue(i.ToString(), result) as IHTMLElement; + var element1 = resultAsExpando.GetValue(i.ToString()) as IHTMLElement; if (element1 != null) yield return new IEElement(element1); } } @@ -54,25 +52,5 @@ { return GetEnumerator(); } - - public object GetPropertyValue(string propertyName, object hasExpandoInterface) - { - var expando = (IExpando)hasExpandoInterface; - - var property = expando.GetProperty(propertyName, BindingFlags.Default); - if (property != null) - { - try - { - return property.GetValue(hasExpandoInterface, null); - } - catch (COMException) - { - return null; - } - } - - return null; - } } } \ No newline at end of file Modified: trunk/src/Core/Native/Windows/Window.cs =================================================================== --- trunk/src/Core/Native/Windows/Window.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/Core/Native/Windows/Window.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -137,7 +137,17 @@ public virtual string ProcessName { - get { return Process.GetProcessById(ProcessID).ProcessName; } + get + { + try + { + return Process.GetProcessById(ProcessID).ProcessName; + } + catch + { + return null; + } + } } public string Message Modified: trunk/src/UnitTests/AttributeConstraintTests/FindBySelectorTests.cs =================================================================== --- trunk/src/UnitTests/AttributeConstraintTests/FindBySelectorTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/AttributeConstraintTests/FindBySelectorTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -175,7 +175,63 @@ Assert.That(sb.ToString(), Is.EqualTo("Selector = '.Return >this'")); } + [Test, Ignore("Bug: Queryselector can't be used to find Frames in IE")] + public void Should_find_frame() + { + ExecuteTest(browser => + { + // GIVEN + browser.GoTo(FramesetURI); + // WHEN + var frame = browser.Frame(Find.BySelector("")); + + // THEN + Assert.That(frame == null); + }); + } + + [Test] + public void Should_find_element_in_frame() + { + ExecuteTest(browser => + { + // GIVEN + browser.GoTo(FramesetURI); + var frame = browser.Frame("mainid"); + + // WHEN + var link = frame.Link(Find.BySelector("#Microsoft")); + + // THEN + Assert.That(link.Exists); + Assert.That(link.Id, Is.EqualTo("Microsoft")); + }); + } + + [Test, Ignore("Bug: Queryselector not working with Frames in IE")] + public void Should_find_element_in_frame_within_frame() + { + ExecuteTest(browser => + { + // GIVEN + browser.GoTo(FramesetWithinFramesetURI); + var frame1 = browser.Frame("mainid"); + Console.WriteLine(frame1.FrameElement.GetJavascriptElementReference()); + var frame2 = frame1.Frame("mainid"); + var javascriptElementReference = frame2.FrameElement.GetJavascriptElementReference(); + Console.WriteLine(javascriptElementReference); + + + // WHEN + var link = frame2.Link(Find.BySelector("#Microsoft")); + + // THEN + Assert.That(link.Exists); + }); + } + + public override Uri TestPageUri { get { return MainURI; } Modified: trunk/src/UnitTests/AttributeConstraintTests/ProximityTests.cs =================================================================== --- trunk/src/UnitTests/AttributeConstraintTests/ProximityTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/AttributeConstraintTests/ProximityTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -66,7 +66,11 @@ string endingHtml = Ie.Html; // If these don't match, reset the browser so further tests are not affected by this one - if (endingHtml != _startingHtml) Ie.Reopen(); + if (endingHtml != _startingHtml) + { + Ie.Reopen(); + Ie.GoTo(TestPageUri); + } // Now record the test result Assert.That( endingHtml, Is.EqualTo( _startingHtml ), "HTML in the page changed while the test executed." ); Modified: trunk/src/UnitTests/ButtonTests.cs =================================================================== --- trunk/src/UnitTests/ButtonTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/ButtonTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -348,7 +348,7 @@ { var browserVersion = 7; var ieUserAgent = browser.Eval("window.navigator.userAgent"); - if (!string.IsNullOrEmpty(ieUserAgent) && new Regex(@"MSIE 8(\.\d+);").IsMatch(ieUserAgent)) + if (!string.IsNullOrEmpty(ieUserAgent) && new Regex(@"MSIE [8-9](\.\d+);").IsMatch(ieUserAgent)) { browserVersion = 8; } Modified: trunk/src/UnitTests/CheckBoxTests.cs =================================================================== --- trunk/src/UnitTests/CheckBoxTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/CheckBoxTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -124,6 +124,7 @@ // The new way to do this var checkBox21b = browser.CheckBox(new LabelTextConstraint("label for Checkbox21")); + Assert.That(checkBox21b.Exists, "Checkbox21 not found using LabelTextConstraint."); Assert.AreEqual(checkBox21a.Id, checkBox21b.Id, "Checkbox attached to Label for Checkbox21 did not match CheckBox21."); // The old way to do this Modified: trunk/src/UnitTests/DialogHandlerTests/AlertDialogHandlerTests.cs =================================================================== --- trunk/src/UnitTests/DialogHandlerTests/AlertDialogHandlerTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/DialogHandlerTests/AlertDialogHandlerTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -18,6 +18,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; using WatiN.Core.DialogHandlers; using WatiN.Core.UnitTests.TestUtils; using WatiN.Core.UtilityClasses; @@ -49,26 +50,6 @@ } } - [Test] - public void Should_handle_alert_dialog_browser_agnostic() - { - ExecuteTest(browser => - { - // GIVEN - var dialogHandler = new JSAlertDialogHandler(browser); - dialogHandler.InjectStub(); - - // WHEN - browser.Button(Find.ByValue("Show alert dialog")).Click(); - - dialogHandler.RevertStub(); - - // THEN - Assert.That(true); - }); - } - - [Test, Ignore("This feature can't be supported on IE8 because there is no way to detect the parent ie/window for a dialog.")] public void CloseSpecificBrowserAlert() { @@ -142,12 +123,78 @@ } } + [Test] + public void Should_handle_alert_dialog_browser_agnostic() + { + ExecuteTest(browser => + { + // GIVEN + browser.DialogWatcher.CloseUnhandledDialogs = false; + + var dialogHandler = new JSAlertDialogHandler(browser); + dialogHandler.InjectStub(); + + // WHEN + browser.Button(Find.ByValue("Show alert dialog")).Click(); + var message = dialogHandler.Message; + + dialogHandler.RevertStub(); + + // THEN + Assert.That(message, Is.EqualTo("This is an alert!")); + }); + } + + [Test] + public void Should_handle_alert_dialog_browser_agnostic2() + { + ExecuteTest(browser => + { + // GIVEN + browser.DialogWatcher.CloseUnhandledDialogs = false; + + var dialogHandler = new JSAlertDialogHandler2(browser, () => browser.Button(Find.ByValue("Show alert dialog")).Click()); + + // WHEN + dialogHandler.DoAction(); + + // THEN + Assert.That(dialogHandler.Message, Is.EqualTo("This is an alert!")); + }); + } + + public override Uri TestPageUri { get { return TestEventsURI; } } } + + + public class JSAlertDialogHandler2:JSAlertDialogHandler + { + private readonly Action _actionToInvokeShowAlertDialog; + private string _message; + + public JSAlertDialogHandler2(Document document, Action actionToInvokeShowAlertDialog) : base(document) + { + _actionToInvokeShowAlertDialog = actionToInvokeShowAlertDialog; + } + + public void DoAction() + { + InjectStub(); + _actionToInvokeShowAlertDialog.Invoke(); + _message = base.Message; + RevertStub(); + } + + public override string Message + { + get { return _message; } + } + } public class JSAlertDialogHandler { private static VariableNameHelper VariableNameHelper= new VariableNameHelper("watinalertdialog"); @@ -161,9 +208,14 @@ _orgAlertFunction = VariableNameHelper.CreateVariableName(); } + public virtual string Message + { + get { return _document.Eval("window._watinalertmessage"); } + } + public void InjectStub() { - var code = _orgAlertFunction + " = window.alert; window.alert = function(){ return true; }"; + var code = _orgAlertFunction + " = window.alert; window.alert = function(message){ window._watinalertmessage = message; return true; }"; _document.RunScript(code); } Modified: trunk/src/UnitTests/DialogHandlerTests/ReturnJavaDialogHandlerTest.cs =================================================================== --- trunk/src/UnitTests/DialogHandlerTests/ReturnJavaDialogHandlerTest.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/DialogHandlerTests/ReturnJavaDialogHandlerTest.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -16,17 +16,13 @@ #endregion Copyright -using System; using System.Threading; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; using SHDocVw; using WatiN.Core.Constraints; using WatiN.Core.DialogHandlers; -using WatiN.Core.Exceptions; -using WatiN.Core.Interfaces; -using WatiN.Core.Native.Windows; using WatiN.Core.UnitTests.TestUtils; -using WatiN.Core.UtilityClasses; namespace WatiN.Core.UnitTests.DialogHandlerTests { @@ -34,61 +30,49 @@ public class ReturnJavaDialogHandlerTest : BaseWatiNTest { [Test] - public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnOkShouldCloseIE() + public void Should_return_browser_specific_version_of_handler() { - using (var ie = new IE(OnBeforeUnloadJavaDialogURI)) - { - var returnDialogHandler = new ReturnDialogHandler(); - ie.AddDialogHandler(returnDialogHandler); + // GIVEN + var ie_version = IE.GetMajorIEVersion(); - var hWnd = ie.hWnd; - // can't use ie.Close() here cause this will cleanup the registered - // returnDialogHandler which leads to a timeout on the WaitUntilExists - var internetExplorer = (IWebBrowser2)ie.InternetExplorer; - internetExplorer.Quit(); + // WHEN + var handler = ReturnDialogHandler.CreateInstance(); - returnDialogHandler.WaitUntilExists(); - returnDialogHandler.OKButton.Click(); - - Thread.Sleep(2000); - Assert.IsFalse(Browser.Exists<IE>(new AttributeConstraint("hwnd", hWnd.ToString()))); - } + // THEN + if (ie_version < 9) + Assert.That(handler, Is.InstanceOfType(typeof(ReturnDialogHandler))); + else + Assert.That(handler, Is.InstanceOfType(typeof(ReturnDialogHandlerIe9))); } [Test] - public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnCancelShouldKeepIEOpen() + public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnOkShouldCloseIE() { using (var ie = new IE(OnBeforeUnloadJavaDialogURI)) { - var returnDialogHandler = new ReturnDialogHandler(); + var returnDialogHandler = ReturnDialogHandler.CreateInstance(); ie.AddDialogHandler(returnDialogHandler); var hWnd = ie.hWnd; - // can't use ie.Close() here cause this will cleanup the registered // returnDialogHandler which leads to a timeout on the WaitUntilExists var internetExplorer = (IWebBrowser2)ie.InternetExplorer; internetExplorer.Quit(); returnDialogHandler.WaitUntilExists(); - returnDialogHandler.CancelButton.Click(); + returnDialogHandler.OKButton.Click(); Thread.Sleep(2000); - Assert.IsTrue(Browser.Exists<IE>(new AttributeConstraint("hwnd", hWnd.ToString()))); - - // finally close the ie instance - internetExplorer.Quit(); - returnDialogHandler.WaitUntilExists(); - returnDialogHandler.OKButton.Click(); + Assert.IsFalse(Browser.Exists<IE>(new AttributeConstraint("hwnd", hWnd.ToString()))); } } [Test] - public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnCancelShouldKeepIE9Open() + public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnCancelShouldKeepIEOpen() { using (var ie = new IE(OnBeforeUnloadJavaDialogURI)) { - var returnDialogHandler = new ReturnDialogHandlerIE9(); + var returnDialogHandler = ReturnDialogHandler.CreateInstance(); ie.AddDialogHandler(returnDialogHandler); var hWnd = ie.hWnd; @@ -108,91 +92,10 @@ internetExplorer.Quit(); returnDialogHandler.WaitUntilExists(); returnDialogHandler.OKButton.Click(); - } - } - } - public class ReturnDialogHandlerIE9 : BaseDialogHandler - { - private Window _window; - - public WinButton CancelButton - { - get - { - var hwnd = GetChildWindowHwnd(_window.Hwnd, "5000200E"); - return hwnd != IntPtr.Zero? new WinButton(hwnd) : null; + Thread.Sleep(2000); + Assert.IsFalse(Browser.Exists<IE>(new AttributeConstraint("hwnd", hWnd.ToString()))); } } - - public WinButton OKButton - { - get - { - var hwnd = GetChildWindowHwnd(_window.Hwnd, "5000200F"); - return hwnd != IntPtr.Zero ? new WinButton(hwnd) : null; - } - } - - public override bool HandleDialog(Window window) - { - if (CanHandleDialog(window)) - { - _window = window; - - while (window.Exists()) - { - Thread.Sleep(200); - } - return true; - } - return false; - } - - public override bool CanHandleDialog(Window window) - { - return (window.StyleInHex == "96C00284"); - } - - public void WaitUntilExists(int waitDurationInSeconds) - { - var tryActionUntilTimeOut = new TryFuncUntilTimeOut(TimeSpan.FromSeconds(waitDurationInSeconds)); - tryActionUntilTimeOut.Try(() => Exists()); - - if (!Exists()) - { - throw new WatiNException(string.Format("Dialog not available within {0} seconds.", waitDurationInSeconds)); - } - } - - public bool Exists() - { - return _window != null && _window.Exists(); - } - - private IntPtr GetChildWindowHwnd(IntPtr parentHwnd, string styleInHex) - { - var hWnd = IntPtr.Zero; - NativeMethods.EnumChildWindows(parentHwnd, (childHwnd, lParam) => - { - var window = new Window(childHwnd); - Console.WriteLine("childhwnd: " + childHwnd); - Console.WriteLine("childhwnd.styleinhex: " + window.StyleInHex); - if (window.StyleInHex == styleInHex) - { - hWnd = childHwnd; - return false; - } - - return true; - }, IntPtr.Zero); - - return hWnd; - } - - public void WaitUntilExists() - { - WaitUntilExists(30); - } } } \ No newline at end of file Modified: trunk/src/UnitTests/DocumentTests.cs =================================================================== --- trunk/src/UnitTests/DocumentTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/DocumentTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -532,8 +532,10 @@ // WHEN var outerHtml = browser.Html.ToLowerInvariant(); + outerHtml = outerHtml.Replace("\r\n", ""); + // THEN - Assert.That(outerHtml, NUnit.Framework.SyntaxHelpers.Text.StartsWith("\r\n<body style=")); + Assert.That(outerHtml, NUnit.Framework.SyntaxHelpers.Text.StartsWith("<body style=")); }); } } Modified: trunk/src/UnitTests/ElementTests.cs =================================================================== --- trunk/src/UnitTests/ElementTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/ElementTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -538,7 +538,37 @@ Assert.IsTrue(injectedDivTextField.Exists); }); } + [Test] + public void WaitUntilElementExistsElementInjectionAfter3SecondsShouldWorkForFramesAsWell() + { + ExecuteTest(browser => + { + Assert.IsTrue(Settings.WaitUntilExistsTimeOut > 3, "Settings.WaitUntilExistsTimeOut must be more than 3 seconds"); + + browser.GoTo(new Uri(HtmlTestBaseURI, "Frameset2.html")); + var frame = browser.Frame("mainid"); + var injectedTextField = frame.TextField("injectedTextField"); + var injectedDivTextField = frame.Div("seconddiv").TextField("injectedTextField"); + + Assert.IsFalse(injectedTextField.Exists); + Assert.IsFalse(injectedDivTextField.Exists); + + frame.Button("injectElement").ClickNoWait(); + + Assert.IsFalse(injectedTextField.Exists); + Assert.IsFalse(injectedDivTextField.Exists); + + // WatiN should wait until the element exists before + // getting the text. + var text = injectedTextField.Text; + + Assert.IsTrue(injectedTextField.Exists); + Assert.AreEqual("Injection Succeeded", text); + Assert.IsTrue(injectedDivTextField.Exists); + }); + } + [Test] public void WaitUntilElementRemovedAfter3Seconds() { Modified: trunk/src/UnitTests/FrameCrossDomainTests.cs =================================================================== --- trunk/src/UnitTests/FrameCrossDomainTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/FrameCrossDomainTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -18,6 +18,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; using WatiN.Core.UnitTests.TestUtils; namespace WatiN.Core.UnitTests @@ -45,7 +46,7 @@ } catch(Exception e) { - Assert.Fail("Unexpected exception: " + e.GetType()); + Assert.Fail("Unexpected exception: " + e.Message); } Assert.AreEqual("mainid", browser.Frames[1].Id, "Unexpected id"); @@ -85,7 +86,8 @@ { try { - Assert.That(browser.Frame("contentsid").Link("googlelink").Exists, "Should find link"); + var frame = browser.Frame("contentsid"); + Assert.That(frame.Link("googlelink").Exists, "Should find link"); } catch (UnauthorizedAccessException) { @@ -93,7 +95,7 @@ } catch (Exception e) { - Assert.Fail("Unexpected exception: " + e.GetType()); + Assert.Fail("Unexpected exception: " + e.StackTrace); } Assert.AreEqual("contentsid", browser.Frame("contentsid").Id, "Unexpected Id"); Modified: trunk/src/UnitTests/FramesetWithinFrameSetTests.cs =================================================================== --- trunk/src/UnitTests/FramesetWithinFrameSetTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/FramesetWithinFrameSetTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -18,6 +18,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; using WatiN.Core.UnitTests.TestUtils; namespace WatiN.Core.UnitTests @@ -35,6 +36,28 @@ }); } + [Test, Ignore("Bug: Events not fired in nested Frames in IE")] + public void Should_navigate_to_google() + { + ExecuteTest(browser => + { + // GIVEN + var frame = browser.Frame("mainid"); + Console.WriteLine(frame.FrameElement.GetJavascriptElementReference()); + + var nestedFrame = frame.Frame("mainid"); + var javascriptElementReference = nestedFrame.FrameElement.GetJavascriptElementReference(); + Console.WriteLine(javascriptElementReference); + Console.WriteLine("not null: " + browser.Eval(javascriptElementReference + " != null")); + + // WHEN + nestedFrame.Link("googlelink").MouseUp(); + + // THEN + Assert.That(nestedFrame.Url, Text.Contains("google")); + }); + } + public override Uri TestPageUri { get { return FramesetWithinFramesetURI; } Modified: trunk/src/UnitTests/IFramesTests.cs =================================================================== --- trunk/src/UnitTests/IFramesTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/IFramesTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -162,5 +162,43 @@ // create a better test. using (new IE(EbayUrl)) {} } + + [Test] + public void Should_find_element_inside_iframe_contained_in_frame() + { + ExecuteTest(browser => + { + // GIVEN + browser.GoTo(iFramesWithinFramesetURI); + var mainFrame = browser.Frame("mainid"); + + // When + var frame = mainFrame.Frame(Find.ByName("middle")); + var select = frame.SelectList(Find.ByName("select1")); + + // Then + Assert.That(frame.Name, Is.EqualTo("middle"), "Unexpected frame name"); + Assert.That(select.Exists, "Expected 'select1' to exist"); + }); + } + + [Test] + public void Should_find_element_inside_frame_contained_in_iframe() + { + ExecuteTest(browser => + { + // GIVEN + browser.GoTo(FramesWithinIFrameURI); + var mainFrame = browser.Frame(Find.ByName("middle")); + + // When + var frame = mainFrame.Frame(Find.ByName("contents")); + var link = frame.Link("Microsoft"); + + // Then + Assert.That(frame.Name, Is.EqualTo("contents"), "Unexpected frame name"); + Assert.That(link.Exists, "Expected 'Microsoft' link to exist"); + }); + } } } \ No newline at end of file Modified: trunk/src/UnitTests/Native/FireFoxTests/FireEventTests.cs =================================================================== --- trunk/src/UnitTests/Native/FireFoxTests/FireEventTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/Native/FireFoxTests/FireEventTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -1,4 +1,22 @@ -using System; +#region WatiN Copyright (C) 2006-2011 Jeroen van Menen + +//Copyright 2006-2011 Jeroen van Menen +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion Copyright + +using System; using System.Collections.Specialized; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; Modified: trunk/src/UnitTests/SelectListTests.cs =================================================================== --- trunk/src/UnitTests/SelectListTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/SelectListTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -22,6 +22,7 @@ using NUnit.Framework; using WatiN.Core.DialogHandlers; using WatiN.Core.Exceptions; +using WatiN.Core.Native.InternetExplorer; using WatiN.Core.UnitTests.TestUtils; namespace WatiN.Core.UnitTests @@ -255,20 +256,38 @@ [Test] public void OptionsInSingelSelectList() { - ExecuteTest(browser => + ExecuteTestWithAnyBrowser(browser => { - var selectList = browser.SelectList("Select1"); + var selectList = browser.SelectList("Select1"); + WriteSelected(selectList); Assert.IsFalse(selectList.Option("Third text").Selected); - selectList.Option("Third text").Select(); - Assert.IsTrue(selectList.Option("Third text").Selected); - selectList.Option("First text").SelectNoWait(); + + selectList.Option("Third text").Select(); + WriteSelected(selectList); + Assert.IsTrue(selectList.Option("Third text").Selected); + + selectList.Option("First text").SelectNoWait(); browser.WaitForComplete(); - Assert.IsFalse(selectList.Option("Third text").Selected); + WriteSelected(selectList); + Assert.IsFalse(selectList.Option("Third text").Selected); }); } - [Test] + private void WriteSelected(SelectList selectList) + { + foreach (var option in selectList.Options) + { + Console.Write(option.Selected + ", "); + var nativeElement = (IEElement)option.NativeElement; + + var htmlOptionElement = (mshtml.IHTMLOptionElement)nativeElement.AsHtmlElement; + Console.WriteLine(htmlOptionElement.selected); + } + Console.WriteLine("----"); + } + + [Test] public void OptionsInMultiSelectList() { ExecuteTest(browser => Modified: trunk/src/UnitTests/TestUtils/BaseWatiNTest.cs =================================================================== --- trunk/src/UnitTests/TestUtils/BaseWatiNTest.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/TestUtils/BaseWatiNTest.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -33,6 +33,8 @@ public static Uri PopUpURI = new Uri(HtmlTestBaseURI, "popup.html"); public static Uri FramesetURI = new Uri(HtmlTestBaseURI, "Frameset.html"); public static Uri FramesetWithinFramesetURI = new Uri(HtmlTestBaseURI, "FramesetWithinFrameset.html"); + public static Uri iFramesWithinFramesetURI = new Uri(HtmlTestBaseURI, "iframes\\iFramesWithinFrameset.html"); + public static Uri FramesWithinIFrameURI = new Uri(HtmlTestBaseURI, "iframes\\FramesetWithinIFrame.html"); public static Uri CrossDomainFramesetURI = new Uri(HtmlTestBaseURI, "CrossDomainFrameset.html"); public static Uri TestEventsURI = new Uri(HtmlTestBaseURI, "TestEvents.html"); public static Uri FormSubmitURI = new Uri(HtmlTestBaseURI, "formsubmit.html"); Modified: trunk/src/UnitTests/TextFieldTests.cs =================================================================== --- trunk/src/UnitTests/TextFieldTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/TextFieldTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -61,11 +61,15 @@ { ExecuteTest(browser => { + // GIVEN var textfieldName = browser.TextField("Textarea1"); var textWithNewLine = "Line1" + Environment.NewLine + "Line2"; + // WHEN textfieldName.TypeText(textWithNewLine); - Assert.AreEqual(textWithNewLine, textfieldName.Value); + + // THEN + Assert.AreEqual(textWithNewLine, textfieldName.Value); }); } Modified: trunk/src/UnitTests/UnitTests.csproj =================================================================== --- trunk/src/UnitTests/UnitTests.csproj 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/UnitTests.csproj 2011-04-12 08:59:53 UTC (rev 1195) @@ -149,7 +149,7 @@ <Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.mshtml"> <HintPath>..\..\lib\Net\3.5\Microsoft.mshtml.dll</HintPath> - <EmbedInteropTypes>True</EmbedInteropTypes> + <EmbedInteropTypes>False</EmbedInteropTypes> </Reference> <Reference Include="Moq, Version=2.6.1014.1, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> @@ -435,6 +435,9 @@ <Content Include="html\BodyNotExistsBug.htm" /> <Content Include="html\ButtonTests.html" /> <Content Include="html\ClassConstraintTests.html" /> + <Content Include="html\iframes\FramesetWithinIFrame.html" /> + <Content Include="html\iframes\iFramesWithinFrameset.html" /> + <Content Include="html\Frameset2.html" /> <Content Include="html\ListTests.html" /> <Content Include="html\CrossDomainFrameset.html" /> <Content Include="html\formsubmit.html" /> Modified: trunk/src/UnitTests/WatiNSanityTests.cs =================================================================== --- trunk/src/UnitTests/WatiNSanityTests.cs 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/WatiNSanityTests.cs 2011-04-12 08:59:53 UTC (rev 1195) @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using System.Reflection; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; @@ -34,6 +35,27 @@ public class WatiNSanityTests : BaseWatiNTest { [Test] + public void ShouldEnsureThatEachHtmlFileHasA_X_UA_Compatible_metaTag() + { + var htmlFiles = Directory.GetFiles(HtmlTestBaseURI.AbsolutePath, "*.htm*", SearchOption.AllDirectories); + var fail = false; + foreach (var htmlFile in + htmlFiles.Where(htmlFile => htmlFile.EndsWith("html", true, CultureInfo.InvariantCulture) || (htmlFile.EndsWith("htm", true, CultureInfo.InvariantCulture)))) + { + Console.WriteLine(); + + var fileText = File.ReadAllText(htmlFile); + + if (fileText.Contains("<meta http-equiv=\"X-UA-Compatible\" content=\"IE")) continue; + + fail = true; + Console.WriteLine(htmlFile); + Console.WriteLine("Does not contian: <meta http-equiv=\"X-UA-Compatible\" content=\"IE"); + } + + Assert.That(fail, Is.False, "Not all test html files are correctly Marked Of The Web. Make sure the files are ANSI encoded."); + } + [Test] public void ShouldEnsureThatEachHtmlFileHasAProperMarkOfTheWebComment() { var htmlFiles = Directory.GetFiles(HtmlTestBaseURI.AbsolutePath, "*.htm*", SearchOption.AllDirectories); @@ -154,7 +176,9 @@ "Page.get_Metadata", "Page.get_Document", "IE.get_Visible", - "IE.set_Visible" + "IE.set_Visible", + "Frame.get_FrameElement" + }; string missedProperties = null; @@ -215,7 +239,8 @@ "Page.get_Metadata", "Page.get_Document", "IE.get_Visible", - "IE.set_Visible" + "IE.set_Visible", + "Frame.get_FrameElement" }; string missedMethods = null; Modified: trunk/src/UnitTests/html/BodyNotExistsBug.htm =================================================================== --- trunk/src/UnitTests/html/BodyNotExistsBug.htm 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/html/BodyNotExistsBug.htm 2011-04-12 08:59:53 UTC (rev 1195) @@ -2,6 +2,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>WatiN Test</title> </head> <body> Modified: trunk/src/UnitTests/html/ButtonTests.html =================================================================== --- trunk/src/UnitTests/html/ButtonTests.html 2011-03-29 13:57:47 UTC (rev 1194) +++ trunk/src/UnitTests/html/ButtonTests.html 2011-04-12 08:59:53 UTC (rev 1195) @@ -2,7 +2,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> - <meta http-equiv="X-UA-Compatible" content="IE=8" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>ButtonTests</title> <script type="text/javascript"> Modified: trunk/src/UnitTests/html/ClassConstraintTests.html ========... [truncated message content] |