public void RecordedMethod()
{
#region Variable Declarations
WinButton uIItem30828CI1Button = this.UIHttpmgluca10000sitesWindow.UIItem30828CI1ListItem.UIItem30828CI1Button;
WinButton uIWorkflowsButton = this.UIHttpmgluca10000sitesWindow.UIWorkflowsListItem.UIWorkflowsButton;
WinListItem uIRe10ListItem = this.UIHttpmgluca10000sitesWindow.UIItemWindow1.UIItemList.UIRe10ListItem;
WinButton uIPublishButton = this.UIHttpmgluca10000sitesWindow.UIItemWindow.UISaveToolBar.UIPublishButton;
WinEdit uIAddressEdit = this.UIMsnWindowsInternetExWindow.UIItemWindow.UIAddressBarClient.UIAddressEdit;
BrowserWindow uIMsnWindowsInternetExWindow = this.UIMsnWindowsInternetExWindow;
HtmlHyperlink uIShareHyperlink = this.UIMsnWindowsInternetExWindow.UIWorkflowSettingsDocument.UIShareHyperlink;
HtmlDocument uIWorkflowSettingsDocument = this.UIMsnWindowsInternetExWindow.UIWorkflowSettingsDocument;
#endregion
// Launch '%ProgramW6432%\Microsoft Office\Office15\SPDESIGN.EXE'(打开SPD)
ApplicationUnderTest sPDESIGNApplication = ApplicationUnderTest.Launch(this.RecordedMethod4Params.ExePath, this.RecordedMethod4Params.AlternateExePath);
// Click '30828CI1' button(点击相应的站点)
Mouse.Click(uIItem30828CI1Button, new Point(48, 10));
// Click 'Workflows' button(点击Workflows)
Mouse.Click(uIWorkflowsButton, new Point(54, 7));
// Click 're10' list item(点击相应的Workflow)
Mouse.Click(uIRe10ListItem, new Point(35, 13));
// Click 'Publish' button(点击Publish按钮)
Mouse.Click(uIPublishButton, new Point(13, 31));
// Go to web page 'http://go.microsoft.com/fwlink/p/?LinkId=255141' using new browser instance(打开浏览器)
this.UIMsnWindowsInternetExWindow.LaunchUrl(new System.Uri(this.RecordedMethod4Params.UIMsnWindowsInternetExWindowUrl));
// Click 'Address' text box(点击浏览器地址栏)
Mouse.Click(uIAddressEdit, new Point(216, 2));
// Go to web page 'http://mglu-ca:10000/sites/30828CI1/_layouts/15/WrkSetng.aspx?List={C9B1EDD4-8B24-4115-9753-3113D02BE3C1}'(输入Workflow Settings页面的地址)
uIMsnWindowsInternetExWindow.NavigateToUrl(new System.Uri(this.RecordedMethod4Params.UIMsnWindowsInternetExWindowUrl1));
// Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
Playback.PlaybackSettings.ContinueOnError = true;
// Mouse hover 'Share' link at (8, 3)
Mouse.Hover(uIShareHyperlink, new Point(8, 3));
// Reset flag to ensure that play back stops if there is an error.
Playback.PlaybackSettings.ContinueOnError = false;
int i=0;
while (i < 350)
{
// Click 'Publish' button(点击Publish按钮)
Mouse.Click(uIPublishButton, new Point(23, 31));
// Type '{F5}' in 'Workflow Settings' document(刷新Workflow Settings页面)
Keyboard.SendKeys(uIWorkflowSettingsDocument, this.RecordedMethod4Params.UIWorkflowSettingsDocumentSendKeys, ModifierKeys.None);
}
}
就这样,一个自动化创建SPD Workflow的任务就完成了,还挺快的,一分钟差不多创建10个SPD Workflow左右,半个小时左右弄完。
不过这是通过最接近用户操作的方法实现的,却不是通过直接调用相关API实现的。
还希望有大神能给出直接调用相关API实现Publish SPD Workflow的方法,共同学习,共同进步。