本文整理汇总了C#中TestStack.White.UIItems.WindowItems.Window.ModalWindows方法的典型用法代码示例。如果您正苦于以下问题:C# Window.ModalWindows方法的具体用法?C# Window.ModalWindows怎么用?C# Window.ModalWindows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestStack.White.UIItems.WindowItems.Window
的用法示例。
在下文中一共展示了Window.ModalWindows方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckWindowExists
//**************************************************************************************************************************************************************
public static bool CheckWindowExists(Window mainWindow, string childWindowName)
{
bool window = false;
try
{
List<Window> allChildWindows = mainWindow.ModalWindows();
foreach (Window w in allChildWindows)
{
if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
{
window = true;
Thread.Sleep(int.Parse(Execution_Speed));
break;
}
}
return window;
}
catch (Exception e)
{
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例2: ResetQBWindows
//**************************************************************************************************************************************************************
public static void ResetQBWindows(TestStack.White.Application qbApp, Window qbWin)
{
List<Window> modalWin = null;
int iteration = 0;
try
{
do
{
if (iteration <= 10)
{
iteration = iteration + 1;
modalWin = qbWin.ModalWindows();
foreach (Window item in modalWin)
{
//Alert window handler
try
{
Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "OK");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch (Exception) { }
try
{
Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "No");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch (Exception) { }
//Register QB window handler
if (item.Name.Contains("Register QuickBooks"))
{
try
{
Actions.ClickElementByName(item, "Remind Me Later");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch { }
}
//No company window handler
else if (item.Name.Contains("No"))
{
try
{
QuickBooks.OpenOrUpgradeCompanyFile(DefaultCompanyFilePath, qbApp, qbWin, false, false);
}
catch { }
}
//Update quickbooks window handler
else if (item.Name.Contains("Update QuickBooks"))
{
try
{
Actions.ClickElementByName(item, "Close");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch { }
}
//Payroll update window handler
else if (item.Name.Equals("Payroll Update"))
{
try
{
Actions.ClickElementByName(item, "Cancel");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch { }
try
{
Actions.ClickElementByName(item, "OK");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch { }
}
//Intuit payroll services window hadler
else if (item.Name.Contains("Intuit Payroll Services"))
{
try
{
Actions.ClickElementByName(item, "OK");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch { }
}
//Employer services window handler
else if (item.Name.Contains("Employer Services"))
{
try
{
Actions.ClickElementByName(item, "Cancel");
//.........这里部分代码省略.........
示例3: OpenOrUpgradeCompanyFile
//**************************************************************************************************************************************************************
public static void OpenOrUpgradeCompanyFile(string companyFilePath, TestStack.White.Application qbApp, Window qbWindow, bool backupcopy, bool portalcopy)
{
try
{
Actions.SelectMenu(qbApp, qbWindow, "File", "Open or Restore Company...");
Thread.Sleep(int.Parse(Execution_Speed));
if (backupcopy)
{
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Restore a backup copy");
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
Thread.Sleep(int.Parse(Execution_Speed));
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Local backup");
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
Thread.Sleep(int.Parse(Execution_Speed));
try
{
Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Open Backup Copy"), "File name:", companyFilePath);
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open Backup Copy"), "Open");
Actions.WaitForChildWindow(qbWindow, "Open or Restore Company", int.Parse(Sync_Timeout));
}
catch (Exception) { }
try
{
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
Thread.Sleep(int.Parse(Execution_Speed));
}
catch (Exception) { }
try
{
Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "File name:", Utils.StringFunctions.RandomString(5));
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "Save");
Actions.WaitForAnyChildWindow(qbWindow, "Save Company File as", int.Parse(Sync_Timeout));
}
catch (Exception) { }
}
else if (portalcopy)
{
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Restore a portable file");
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
Thread.Sleep(int.Parse(Execution_Speed));
try
{
Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Open Portable Company File"), "File name:", companyFilePath);
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open Portable Company File"), "Open");
Actions.WaitForChildWindow(qbWindow, "Open or Restore Company", int.Parse(Sync_Timeout));
}
catch (Exception) { }
try
{
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
Thread.Sleep(int.Parse(Execution_Speed));
}
catch (Exception) { }
try
{
Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "File name:", Utils.StringFunctions.RandomString(5));
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "Save");
Actions.WaitForAnyChildWindow(qbWindow, "Save Company File as", int.Parse(Sync_Timeout));
}
catch (Exception) { }
}
else
{
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Open a company file");
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
Thread.Sleep(int.Parse(Execution_Speed));
Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Open a Company"), "File name:", companyFilePath);
Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open a Company"), "Open");
Actions.WaitForAnyChildWindow(qbWindow, "Open a Company", int.Parse(Sync_Timeout));
}
List<Window> modalWin = null;
int iteration = 0;
do
{
modalWin = qbWindow.ModalWindows();
iteration = iteration + 1;
if (iteration <= 7)
{
foreach (Window item in modalWin)
{
//QB Login window handler
if (item.Name.Contains("QuickBooks Login"))
{
try
{
Actions.SetFocusOnWindow(item);
//.........这里部分代码省略.........
示例4: ResetQBWindows
//**************************************************************************************************************************************************************
public static void ResetQBWindows(TestStack.White.Application qbApp, Window qbWin, bool openFileOnNoCompany)
{
Logger.logMessage(" ResetQBWindows " + " - Begin");
List<Window> modalWin = null;
int iteration = 0;
bool menuEnabled = false;
try
{
do
{
try
{
Logger.logMessage("---------------Try-Catch Block------------------------");
Actions.SelectMenu(qbApp, qbWin, "Window", "Close All");
}
catch (Exception) { }
do
{
//Alert window handler
if (Actions.CheckDesktopWindowExists("Alert"))
Actions.CheckForAlertAndClose("Alert");
//Crash handler
if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
{
Actions.QBCrashHandler();
break;
}
if (iteration <= 10)
{
iteration = iteration + 1;
modalWin = qbWin.ModalWindows();
foreach (Window item in modalWin)
{
//Alert window handler
if (Actions.CheckDesktopWindowExists("Alert"))
Actions.CheckForAlertAndClose("Alert");
//Crash handler
if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
{
Actions.QBCrashHandler();
break;
}
//Enter memorize report window handler
else if (item.Name.Contains("Memorize Report"))
{
try
{
Logger.logMessage("---------------Try-Catch Block------------------------");
Actions.ClickElementByName(item, "No");
Thread.Sleep(int.Parse(Execution_Speed));
}
catch { }
}
//Handle Save commented report popup
else if (item.Name.Contains("Save Your Commented Report?"))
{
try
{
Logger.logMessage("---------------Try-Catch Block------------------------");
Actions.ClickElementByName(item, "No");
Thread.Sleep(int.Parse(Execution_Speed));
}
catch { }
}
try
{
Logger.logMessage("---------------Try-Catch Block------------------------");
if (Actions.CheckMenuEnabled(qbApp, qbWin, "File"))
{
menuEnabled = true;
break;
}
}
catch (Exception)
{ }
//Register QB window handler
if (item.Name.Contains("Register QuickBooks"))
{
try
{
Logger.logMessage("---------------Try-Catch Block------------------------");
Actions.ClickElementByName(item, "Remind Me Later");
Thread.Sleep(int.Parse(ResetWindow_Timeout));
}
catch { }
//.........这里部分代码省略.........
示例5: GetWindow
//**************************************************************************************************************************************************************
public static Window GetWindow(Window win, String winName)
{
Window window = null;
try
{
List<Window> modalWins = win.ModalWindows();
foreach (Window item in modalWins)
{
if(item.Name.Equals(winName) || item.Name.Contains(winName))
{
window = item;
window.Focus();
window.DoubleClick();
Thread.Sleep(int.Parse(Execution_Speed));
}
}
return window;
}
catch (Exception e)
{
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例6: GetChildWindow
//**************************************************************************************************************************************************************
public static Window GetChildWindow(Window mainWindow, string childWindowName)
{
Window childWindow = null;
try
{
List<Window> allChildWindows = mainWindow.ModalWindows();
foreach (Window w in allChildWindows)
{
if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
{
childWindow = w;
break;
}
}
return childWindow;
}
catch (Exception e)
{
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例7: WaitForChildWindow
//**************************************************************************************************************************************************************
public static bool WaitForChildWindow(Window mainWindow, string childWindowName, long timeOut)
{
bool windowFound = false;
long elapsedTime = 0;
var stopwatch = Stopwatch.StartNew();
try
{
do
{
if (windowFound)
break;
elapsedTime = stopwatch.ElapsedMilliseconds;
List<Window> allChildWindows = mainWindow.ModalWindows();
foreach (Window w in allChildWindows)
{
try
{
Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "OK");
Thread.Sleep(int.Parse(Execution_Speed));
}
catch (Exception) { }
try
{
Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "No");
Thread.Sleep(int.Parse(Execution_Speed));
}
catch (Exception) { }
if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
{
windowFound = true;
break;
}
}
}
while (elapsedTime<=timeOut);
return windowFound;
}
catch (Exception e)
{
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例8: CloseAllChildWindows
//**************************************************************************************************************************************************************
public static void CloseAllChildWindows(Window window)
{
try
{
List<Window> modalWindows = window.ModalWindows();
foreach (Window win in modalWindows)
{
win.Focus();
try { FrameworkLibraries.ActionLibs.QBDT.WhiteAPI.Actions.ClickElementByName(win, "Close"); }
catch { }
try { win.Close(); }
catch { }
}
}
catch (Exception e)
{
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例9: CloseAllChildWindows
//**************************************************************************************************************************************************************
public static void CloseAllChildWindows(Window window)
{
Logger.logMessage("Function call @ :" + DateTime.Now);
try
{
List<Window> modalWindows = window.ModalWindows();
foreach (Window win in modalWindows)
{
win.Focus();
try { FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(win, "Close"); }
catch { }
try { win.Close(); }
catch { }
}
Logger.logMessage("CloseAllChildWindows " + window + " - Successful");
Logger.logMessage("------------------------------------------------------------------------------");
}
catch (Exception e)
{
Logger.logMessage("CloseAllChildWindows " + window + " - Failed");
Logger.logMessage(e.Message);
Logger.logMessage("------------------------------------------------------------------------------");
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例10: CheckWindowExists
//**************************************************************************************************************************************************************
public static bool CheckWindowExists(Window mainWindow, string childWindowName)
{
Logger.logMessage("Function call @ :" + DateTime.Now);
bool window = false;
try
{
List<Window> allChildWindows = mainWindow.ModalWindows();
foreach (Window w in allChildWindows)
{
if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
{
window = true;
Thread.Sleep(int.Parse(Execution_Speed));
break;
}
}
Logger.logMessage("CheckWindowExists " + mainWindow + "->" + childWindowName + " - Successful");
Logger.logMessage("------------------------------------------------------------------------------");
return window;
}
catch (Exception e)
{
Logger.logMessage("CheckWindowExists " + mainWindow + "->" + childWindowName + " - Failed");
Logger.logMessage(e.Message);
Logger.logMessage("------------------------------------------------------------------------------");
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例11: WaitForAnyChildWindow
//**************************************************************************************************************************************************************
public static bool WaitForAnyChildWindow(Window mainWindow, string currentWindowName, long timeOut)
{
var qbApp = Actions.GetApp("QuickBooks", "qbw32");
var qbWindow = Actions.GetAppWindow(qbApp, "QuickBooks");
Logger.logMessage("Function call @ :" + DateTime.Now);
Logger.logMessage(" WaitForAnyChildWindow " + mainWindow + "->" + currentWindowName + " - Begin Sync");
bool windowFound = false;
long elapsedTime = 0;
var stopwatch = Stopwatch.StartNew();
try
{
do
{
//Alert window handler
if (Actions.CheckDesktopWindowExists("Alert"))
Actions.CheckForAlertAndClose("Alert");
try { Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Warning"), "OK"); }
catch (Exception) { }
//Crash handler
if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
{
Actions.QBCrashHandler();
break;
}
if (windowFound)
break;
elapsedTime = stopwatch.ElapsedMilliseconds;
List<Window> allChildWindows = mainWindow.ModalWindows();
foreach (Window w in allChildWindows)
{
if (Actions.CheckDesktopWindowExists("Alert"))
Actions.CheckForAlertAndClose("Alert");
try { Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Warning"), "OK"); }
catch (Exception) { }
//Crash handler
if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
{
Actions.QBCrashHandler();
break;
}
if (!w.Name.Equals(currentWindowName) || !w.Name.Contains(currentWindowName))
{
windowFound = true;
w.WaitWhileBusy();
break;
}
}
}
while (elapsedTime <= timeOut);
Logger.logMessage(" WaitForAnyChildWindow " + mainWindow + "->" + currentWindowName + " - End Sync");
Logger.logMessage("------------------------------------------------------------------------------");
return windowFound;
}
catch (Exception e)
{
Logger.logMessage("WaitForAnyChildWindow " + mainWindow + "->" + currentWindowName + " - Terminated");
Logger.logMessage(e.Message);
Logger.logMessage("------------------------------------------------------------------------------");
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例12: GetChildWindow
//**************************************************************************************************************************************************************
public static Window GetChildWindow(Window mainWindow, string childWindowName)
{
Logger.logMessage("Function call @ :" + DateTime.Now);
Window childWindow = null;
try
{
List<Window> allChildWindows = mainWindow.ModalWindows();
foreach (Window w in allChildWindows)
{
if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
{
childWindow = w;
break;
}
}
Logger.logMessage("GetChildWindow " + mainWindow + "->" + childWindowName + " - Successful");
Logger.logMessage("------------------------------------------------------------------------------");
return childWindow;
}
catch (Exception e)
{
Logger.logMessage("GetChildWindow " + mainWindow + "->" + childWindowName + " - Failed");
Logger.logMessage(e.Message);
Logger.logMessage("------------------------------------------------------------------------------");
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}
示例13: GetWindow
//**************************************************************************************************************************************************************
public static Window GetWindow(Window win, String winName)
{
Logger.logMessage("Function call @ :" + DateTime.Now);
Window window = null;
try
{
List<Window> modalWins = win.ModalWindows();
foreach (Window item in modalWins)
{
Logger.logMessage(item.Name);
if (item.Name.Equals(winName) || item.Name.Contains(winName))
{
window = item;
window.Focus();
window.DoubleClick();
Thread.Sleep(int.Parse(Execution_Speed));
}
}
Logger.logMessage("GetWindow " + winName + " - Successful");
Logger.logMessage("------------------------------------------------------------------------------");
return window;
}
catch (Exception e)
{
Logger.logMessage("GetWindow " + winName + " - Failed");
Logger.logMessage(e.Message);
Logger.logMessage("------------------------------------------------------------------------------");
String sMessage = e.Message;
LastException.SetLastError(sMessage);
throw new Exception(sMessage);
}
}