开发者

Watin not recognising confirmation dialog OK button

开发者 https://www.devze.com 2023-03-31 12:47 出处:网络
I recently started a new testing job and my predecessor ran an automation开发者_Python百科 suite using watin, which I\'ve had no previous experience with so I\'m sorry if I\'m not able to give you the

I recently started a new testing job and my predecessor ran an automation开发者_Python百科 suite using watin, which I've had no previous experience with so I'm sorry if I'm not able to give you the relevant information When I run the suite it (against IE 8.0.7601.17514) seems to get stuck when ever there is a confirmation dialog and the next step is to press ok

//Enter invalid data
            var confirmDialog = new ConfirmDialogHandler();
            IE.DialogWatcher.Add(confirmDialog);
            using (new UseDialogOnce(IE.DialogWatcher, confirmDialog))
            {
                //Click to reset data entry
                IE.Page<DataEntryPage>().ResetVoucherButton.ClickNoWait();
                confirmDialog.WaitUntilExists(40000);
                confirmDialog.OKButton.Click();
                WaitForPostBackToComplete.WaitForAsyncPostBackToComplete(IE);
            }

It just hangs there and waits for the time out period to pass.

I thought the problem was with my IEStaticInstanceHelper.cs file but it seems to be correct

using System.Threading;
using WatiN.Core;

namespace WatiN
{
    public class IEStaticInstanceHelper
    {
        private IE _ie;
        private int _ieThread;
        private string _ieHwnd;

        public IE IE
        {
            get
            {
                var currentThreadId = GetCurrentThreadId();
                if (currentThreadId != _ieThread)
                {
                    _ie = IE.AttachTo<IE>(Find.By("hwnd", _ieHwnd));
                    _ieThread = currentThreadId;
                }
                return _ie;
            }
            set
            {
                _ie = value;
                _ieHwnd = _ie.hWnd.ToString();
                _ieThread = GetCurrentThreadId();
            }
        }

        private int GetCurrentThreadId()
        {
            return Thread.CurrentThread.GetHashCode();
        }
    }
}

I've recently rebuilt my computer (well my sysadmin did) and this wasn't an issue before it was rebuilt, but I can't think what may have changed

Any help would be greatly appreciated

Edit

I didn't actually have to change the code, I just had to update my Watin Version as it couldn't handle what ever differences there were between earlier IE 8 dialog boxes and newer ones.


I had a similar problem with IE 9.

I used the following to simulate the shortcut keys on the dialogue

 using (browser)
                    {
                        SendKeys.SendWait("+(%S)");
                    }

Send Keys = http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

Does this help?

0

精彩评论

暂无评论...
验证码 换一张
取 消