|
using System; |
|
using System.Diagnostics; |
|
using System.Threading; |
|
using System.Windows.Automation; |
|
using Winium.Cruciatus.Core; |
|
using Winium.Cruciatus.Elements; |
|
using Winium.Cruciatus.Extensions; |
|
using Winium.Cruciatus.Exceptions; |
|
using System.Drawing; |
|
using System.Linq; |
|
using Winium.Cruciatus; |
|
using System.Runtime.InteropServices; |
|
|
|
namespace Winium |
|
{ |
|
class Program |
|
{ |
|
public static CruciatusElement GetIfExists(By element, CruciatusElement root, double timeout = 60000, int delay = 2500) |
|
{ |
|
var startDateTime = DateTime.Now; |
|
var error = false; |
|
|
|
CruciatusFactory.Settings.SearchTimeout = (int)timeout; |
|
|
|
while ((DateTime.Now - startDateTime).TotalMilliseconds < timeout) |
|
{ |
|
try |
|
{ |
|
|
|
var elementFound = root.FindElement(element); |
|
|
|
|
|
|
|
Debug.WriteLine("Element: " + elementFound.ToString() + " found at " + elementFound.Properties.BoundingRectangle.ToString()); |
|
Console.WriteLine("Element: " + elementFound.ToString() + " found at " + elementFound.Properties.BoundingRectangle.ToString()); |
|
return elementFound; |
|
} |
|
catch (Exception exception) |
|
{ |
|
Debug.WriteLine("Exception: " + exception.Message); |
|
error = true; |
|
} |
|
} |
|
|
|
//if (error) |
|
// Assert.Fail("Was unable to find element: '" + element.ToString() + "'."); |
|
|
|
// return null; // Never result to something. |
|
|
|
throw (new Exception("Element not found.")); |
|
} |
|
|
|
static void Main(string[] args) |
|
{ |
|
|
|
var exePath = @"C:\Users\gilmichael.regalado\AppData\Local\Apps\2.0\P03DO1GQ.5OY\GCYZB1A4.G0J\clie...app_0000000000000000_0001.0000_79e2734e6e4f1aae\Emerson.CSI.ClientShell.exe"; |
|
var pathAssetOutlook = @"C:\Users\gilmichael.regalado\AppData\Local\Apps\2.0\P03DO1GQ.5OY\GCYZB1A4.G0J\clie...app_0000000000000000_0001.0000_79e2734e6e4f1aae\Emerson.CSI.ClientShell.exe"; |
|
|
|
var app = new Cruciatus.Application(pathAssetOutlook); |
|
app.Start("/module:62e9a58c-257d-46dd-91eb-2f0e059224d4"); |
|
|
|
var winLogin = GetIfExists(By.Name("").AndType(ControlType.Window), Cruciatus.CruciatusFactory.Root); |
|
GetIfExists(By.Name("Username"), winLogin).SetText("Gene"); |
|
GetIfExists(By.Name("Password"), winLogin).SetText("Password01"); |
|
GetIfExists(By.Name("Sign in").AndType(ControlType.Button), winLogin).Click(); |
|
|
|
var winAssetOutlook = GetIfExists(By.Name("Asset Outlook").AndType(ControlType.Window), Cruciatus.CruciatusFactory.Root); |
|
var paneAssetOutlook = GetIfExists(By.Name("Emerson Outlook").AndType(ControlType.Pane), winAssetOutlook); |
|
GetIfExists(By.Name("File").AndType(ControlType.Text), winAssetOutlook); |
|
GetIfExists(By.Name("Home").AndType(ControlType.Text), winAssetOutlook); |
|
GetIfExists(By.Name("View").AndType(ControlType.Text), winAssetOutlook); |
|
GetIfExists(By.Name("Search").AndType(ControlType.Text), winAssetOutlook); |
|
|
|
app.Close(); |
|
|
|
// var calc = new Winium.Cruciatus.Application("C:/windows/system32/calc.exe"); |
|
// calc.Start(); |
|
|
|
// var strategy = |
|
// By.AutomationProperty(TreeScope.Subtree, AutomationElement.ClassNameProperty, "Popup") |
|
// .And(AutomationElement.ProcessIdProperty, this.Instance.Current.ProcessId); |
|
|
|
|
|
|
|
// var winFinder = By.Name("Calculator").AndType(ControlType.Window); |
|
// var win = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder); |
|
// var menu = win.FindElementByUid("MenuBar").ToMenu(); |
|
// |
|
// menu.SelectItem("View$Scientific"); |
|
// menu.SelectItem("View$History"); |
|
|
|
// win.FindElementByUid("132").Click(); // 2 |
|
// win.FindElementByUid("93").Click(); // + |
|
// win.FindElementByUid("134").Click(); // 4 |
|
// win.FindElementByUid("97").Click(); // ^ |
|
// win.FindElementByUid("138").Click(); // 8 |
|
// win.FindElementByUid("121").Click(); // = |
|
// GetIfExists(By.Name("Username"), win).Click(); |
|
// |
|
// win.FindElementByName("Username").SetText("Gene"); |
|
// win.FindElementByName("Password").SetText("Password01"); |
|
// win.FindElement(By.Name("Sign in").AndType(ControlType.Button)).Click(); |
|
|
|
// var vibAnalysisFinder = By.Name("Vibration Analysis").AndType(ControlType.Window); |
|
// var vibAnalysisWindow = Winium.Cruciatus.CruciatusFactory.Root.FindElement(vibAnalysisFinder); |
|
// vibAnalysisWindow.FindElement(By.Name("Emerson Process - ").AndType(ControlType.TreeItem)).Click(); |
|
// Find the Vib Anal window |
|
} |
|
} |
|
} |