watin

Can I read JavaScript alert box with WatiN?

扶醉桌前 提交于 2019-12-20 19:08:06
问题 I want to use WatiN to verify the error message in a JavaScript alert box. Is this possible? Thanks. 回答1: see Trev's Blog and here as well. using(IE ie = new IE("http://hostname/pagename.htm")) { AlertDialogHandler alertDialogHandler = new AlertDialogHandler(); using (new UseDialogOnce(ie.DialogWatcher, alertDialogHandler )) { /************************************* * -- alert -- * * * * must use the "NoWait" to allow * * the code to goto the next line * * * ***********************************

WatiN permissions problem when eval javascript code

筅森魡賤 提交于 2019-12-19 08:13:53
问题 My environment is: WindowXP, IE8, VS2008, WatiN-2.0.20 When i try to execute the follow code: IE _browser = new IE(); _browser.GoTo(_url); _browser.Eval("alert('hello!');"); I get the following error: Message: "Access denied. (Exception of HRESULT: 0x80070005 (E_ACCESSDENIED))" Source: "Microsoft.mshtml" Partial StackTrace in WatiN.Core.Native.InternetExplorer.IEUtils.RunScript(String scriptCode, String language, IHTMLWindow2 window) in WatiN.Core.Native.InternetExplorer.IEDocument.RunScript

WatiN permissions problem when eval javascript code

谁说胖子不能爱 提交于 2019-12-19 08:13:12
问题 My environment is: WindowXP, IE8, VS2008, WatiN-2.0.20 When i try to execute the follow code: IE _browser = new IE(); _browser.GoTo(_url); _browser.Eval("alert('hello!');"); I get the following error: Message: "Access denied. (Exception of HRESULT: 0x80070005 (E_ACCESSDENIED))" Source: "Microsoft.mshtml" Partial StackTrace in WatiN.Core.Native.InternetExplorer.IEUtils.RunScript(String scriptCode, String language, IHTMLWindow2 window) in WatiN.Core.Native.InternetExplorer.IEDocument.RunScript

Browser.ExecScript() stopped working after updating windows

半腔热情 提交于 2019-12-19 03:17:10
问题 I've set up a simple testbed for WatiN (ver 2.1) which reads: var browser = new IE(); browser.GoTo("http://www.google.co.il"); // webpage doesn't matter really browser.RunScript("alert(123)"); This works only if KB3025390 is not installed. Installing it breaks the above test with an UnAuthorizedAccessException which has HRESULT set to E_ACCESSDENIED. What gives? Is there any workaround? Update: Using IWebBrowser2.Navigate2 along with "javascript:console.log(123)" type of scripts works however

WatiN in Visual Studio 2008 - second test method fails

我们两清 提交于 2019-12-18 11:58:19
问题 When trying to run a very simple WatiN 2.0 (CTP3) test in Visual Studio 2008 I found that the first one always executes fine. The second test method seem to break something in the IE object producing the following exception: Test method testProject.WatinTest.testTwo threw exception: System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.. A sample code is below. Due to the way the initialization method is workin in

Watin & IE9 - Cant click ok buttons

假如想象 提交于 2019-12-18 09:01:05
问题 I'm using Watin to navigate through a large number of different websites, and I'm using the great solution here to automatically click ok on all the javascript and ie boxes that popup. The problem is, this solution works great for ie6-ie8, but no longer works for IE9. Does anyone have anyone suggestions on how to get IE9 to auto click/close all prompts? (I'm using the latest Watin release, and the code below) public class something { public something() { IE browser = new IE("about:blank");

WatiN support for HTML5 tags

不羁岁月 提交于 2019-12-18 04:02:41
问题 I have the following HTML: <input type="email" id="email"> I want to type text into it from WatiN : var field = Browser.TextField("email"); Assert.IsTrue(field.Exists); But the field can't be found. This is because WatiN doesn't support HTML5 tags yet. I found a solution to this by creating an extended TextField-class: [ElementTag("input", InputType = "text", Index = 0)] [ElementTag("input", InputType = "password", Index = 1)] [ElementTag("input", InputType = "textarea", Index = 2)]

Pass a key stroke (i.e., Enter Key) into application using WatiN scripts

风格不统一 提交于 2019-12-18 03:16:14
问题 I'm using WatiN testing tool. Can I pass a key stroke (i.e., pressing a enter key) to the application using WatiN scripts? This option was available in WatiR. Is this option available in WatiN? 回答1: EDIT: Upon further inspection, I found that the standard way of sending the ENTER key doesn't work in WatiN as it does in WatiR. You need to use System.Windows.Forms.SendKeys Also, I recommend that you download the WatiN Test Recorder . Here's the sample code. using(IE ie = new IE("http://someurl"

WatiN LogonDialogHandlers not working correctly in Windows 7

时间秒杀一切 提交于 2019-12-17 16:57:07
问题 I have recently updated to Windows 7, VS2010 and IE8. We have an automation suite running tests against IE using WatiN. These tests require the logon dialog handler to be used in order to log different AD Users into the IE Browser. This works perfectly when using Windows XP and IE8, but now using Windows 7 has resulted in the Windows Security dialog box no longer being recognised, the dialogue box is just being ignored. This is the method being used to startup the browser: public static

Design Pattern for C# and invoking different methods based on a string parameter

爱⌒轻易说出口 提交于 2019-12-14 02:29:09
问题 So I am currently about to develop a rather cool library in which I will pull data from an Excel Worksheet or Sharepoint List and then use WatiN and .NET with C# to execute various browser commands for automated UI testing. However, I am running into a big design issue in trying to encapsulate the changing requirements that future commands or tests may need to be generated. Currently, I have about 5 unique actions that I need to perform based on a command parameter (stored as a string in the