watin

Regularly invoking an interactive process (WatiN tests) via Task Scheduler

荒凉一梦 提交于 2019-12-24 03:24:44
问题 I'm using a suite of WatiN tests driving IE to do some periodic sanity checking for the purposes of monitoring a site. The suite works fine when I invoke it interactively and/or when I configure the task in Task Scheduler to "Run only when the user is logged on". However, when I set it to "Run whether the user is logged on or not", and check the "Run with highest privileges" option (WatiN can't talk to the browser satisfactorily under Windows Server 2008 and many other OSes without having

Change IE user agent

浪尽此生 提交于 2019-12-24 01:44:13
问题 I'm using WatiN to automate Internet Explorer, and so far it's been great. However, I would really like to be able to change the user agent of IE so the server thinks it's actually Firefox or some other browser. A Firefox useragent string look something like: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 With the following code RegistryKey ieKey = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0

Getting a list of cookies set using WatiN

只谈情不闲聊 提交于 2019-12-24 00:37:15
问题 Is there a way to get a list of all the cookies set by a website using WatiN? The IE Browser class in WatiN provides a GetCookie method that allows you to retrieve a specific cookie, but I would like to iterate over all the cookies that have been set. There are two methods that should allow you to get the cookies: CookieCollection cookies = _browser.GetCookiesForUrl(new Uri(url)); and CookieContainer cookies = _browser.GetCookieContainerForUrl(new Uri(url)); But both of these are empty. Also

WatiN “Unable to cast COM object” exception

*爱你&永不变心* 提交于 2019-12-22 08:47:49
问题 from time to time, my monitoring application dies for no obvious reason. It seems like "mshtml.HTMLDocument" resource isn't available. Anyone else experienced something similar? Thanks in advance. Error message: 14.04.2011 18:26:37 -> Test 1.2 (Subscriber type requests), error: Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3050F55F-98B5-11CF

ASP.NET Unit Testing - WatiN and Windows 7 / Internet Explorer 8

两盒软妹~` 提交于 2019-12-22 08:34:03
问题 Any tricks in getting WatiN to run on Win7/IE8? My code: browser = new IE(); browser.GoTo("http://testserver"); browser.TextField(Find.ByName("txtUser")).TypeText("tyndall"); The third line never really runs and I get an error back: System.Runtime.InteropServices.COMException : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) The second line seems to run. IE8 appears and is navigated to the correct URL. 回答1: Reboot the machine There are windows updates getting in the way of

WatiN: When finding text, how do I get a reference to its containing element?

久未见 提交于 2019-12-22 05:17:18
问题 Given the following HTML page: <html> <head> <title>WatiN Test</title> </head> <body> <div> <p>Hello World!</p> </div> </body> </html> I would like to be able to search for some text (lets say "World" ), and get a reference to its parent element (in this case the <p> element). If I try this: var element = ie.Element(Find.ByText(t => t.Contains("World"))) or this: var element = ie.Element(e => e.Text != null && e.Text.Contains("World")); I get back the <html> element. This is consistent with

How to handle Windows Security alert dialog box using Watin IE

 ̄綄美尐妖づ 提交于 2019-12-22 05:03:59
问题 I am trying to automate a website using WatIN IE. As the website bans the ip after few request .So I am setting a bool ipbanned =true when ip gets bannned. In that case and i wish to change the IP. The SetProxy method successfully changes the ip adress with port. but on next request I am getting this screen :- Note: - the first red strip shows the ip address and the second one shows the server name How should I set the username and password in this dialog box from within the program, so that

WATIN tests failing with TimeoutException when run from CruiseControl

有些话、适合烂在心里 提交于 2019-12-22 04:57:23
问题 We have a collection of WATIN tests we are using CruiseControl to run every hour. All the tests pass on our local machine - but when they are run using CruiseControl we get sporadic failures. We are using CruiseControl using the command line. We are not using the CruiseControl service. We are using IE8. Before each test is run - we use WATIN to close all instances of the browser to make sure each test is completely isolated. Here is an example of the stack trace we are seeing when the

How to find an Element in Watin by its tag name?

梦想与她 提交于 2019-12-22 04:38:10
问题 How to find a specific element, or a list of elements by using their TagName using Watin? 回答1: As of WatiN 2.0 beta 1 this has changed to: ie.ElementWithTag("h1", constraint); Constraints are created when using the Find.XXX methods. Here is an example: ie.ElementWithTag("h1", Find.ByClass("blue"); 回答2: For example, to find the first <h1> on a page, use: ie.Element("h1", Find.ByIndex(0)) 回答3: this is what worked for me: var element = ie.Element(x => x.Text == "[innerText]" && x.TagName == "

How to scroll Firefox and IE in WatiN?

穿精又带淫゛_ 提交于 2019-12-21 12:37:18
问题 How to scroll Firefox and IE in WatiN? 回答1: You can call the "scrollIntoView" method for either Internet Explorer or FireFox for any given element using the following code: For Internet Explorer: using (var browser = new IE("http://www.google.com")) { var textField = browser.TextField(Find.ByName("q")); var nativeElement = textField.NativeElement as IEElement; nativeElement.AsHtmlElement.scrollIntoView(); } For FireFox: using (var browser = new IE("http://www.google.com")) { var textField =