51Testing软件测试论坛

标题: Coded Ui 和 WatiN 的不同之处 <第二部分> [打印本页]

作者: v_dozhan    时间: 2011-10-20 23:31
标题: Coded Ui 和 WatiN 的不同之处 <第二部分>

Example-Code:
(How to operate Control?)

HtmlInputButton submit = new
HtmlInputButton(htmlDoc);

submit.SearchProperties[HtmlInputButton.PropertyNames.Class] = "SearchButton";

Mouse.Click(submit);

var hhName = ie.Div(Find.ByClass("HighlightedHeader")).Name;var linkUrl = ie.Link(Find.ById("testlinkid")).Url;
var checkbox = ie.CheckBox(Find.ByLabelText("User Name:"));

var checkbox = ie.CheckBox(Find.ByLabelText(new Regex("^User")));
var linkUrl = ie.Link(Find.ByName("testlinkname")).Url;

Example-Code:
(How to drag Control?)

Mouse.startDragging(submit);

Mouse.stopDragging(0,40);

I don’t know how to realize it.

Example-Code:
(How to handle Dialog?)

BrowserWindow bw = BrowserWindow.Launch("http://msdn.microsoft.com/en-us/library/system.xml(printer)");

WinWindow popupWindow = new
WinWindow();

popupWindow.SearchProperties[WinWindow.PropertyNames.Name] = "Print";

WinButton cancelButton = new
WinButton(popupWindow);

cancelButton.SearchProperties[WinButton.PropertyNames.Name] = "Cancel";

Mouse.Click(cancelButton);

bw.Close();

            using (var ie = new IE(new Uri("http://msdn.microsoft.com/en-us/library/system.xml(classic).aspx")))


{


ie.ShowWindow(WatiN.Core.Native.Windows.
NativeMethods.WindowShowStyle.Show);


WatiN.Core.DialogHandlers.
ConfirmDialogHandler dh = new WatiN.Core.DialogHandlers.ConfirmDialogHandler();


ie.AddDialogHandler(dh);


ie.Button(
Find.ById("ctl00_ib1_hlFav")).ClickNoWait();


dh.WaitUntilExists(3);


dh.OKButton.Click();


ie.RemoveDialogHandler(dh);


}

Example-Code:

(How to clear cookie/Cache)

BrowserWindow.ClearCache();

BrowserWindow.ClearCookies();

// Clear the cache and cookies.

IE ie = new IE();

ie.ClearCache();

ie.ClearCookies();

// Then go to the site and sign in.

ie.GoTo("http://www.example.com/");

ie.Link(Find.ByText("Sign In")).Click();
  
  
//***************************Other example*********************************
  // Clear cookies first.
IE ie = new IE();ie.ClearCookies("http://www.example.com/"); // Then go to the site and sign in.ie.GoTo("http://www.example.com/");ie.Link(Find.ByText("Sign In")).Click();

Whether have much code examples:

No

Yes






欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2