51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1739|回复: 0
打印 上一主题 下一主题

[原创] Coded Ui 和 WatiN 的不同之处 <第二部分>

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2011-10-20 23:31:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-14 09:27 , Processed in 0.058988 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表