https://github.com/TestStack/White
using System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Text;using System.Threading;
using TestStack.White;using TestStack.White.Factory;using TestStack.White.UIItems.Finders;
namespace AnotherTestStackApplication{
class Program{#region varaibles
private static TestStack.White.Application _application;
private static TestStack.White.UIItems.WindowItems.Window _mainWindow;
private static TestStack.White.UIItems.ListBoxItems.ListBox _listbox;
private static TestStack.White.UIItems.Button _btnok;
private static List<TestStack.White.UIItems.WindowItems.Window> _allWindows;
static StringBuilder _totalControls= new StringBuilder();
#endregionstatic void Main(string[] args){
try{
_totalControls = new StringBuilder();
//launching ApplicationlaunchApp();
//Reading from main PanelloadingReadingMain();
}
catch (Exception ex){
}
}
static void launchApp(){
try{
// string ExeSourceFPFile = @"E:\TPL\TPL\2014.06.01\Flow and Listed Pricer - Unity\bin\Debug\Unity.exe";//find Exe application, right now in same place-- we need to figure out how to do, may be copy this exe same location_application = Application.Launch("Unity.exe");_mainWindow = _application.GetWindow(
SearchCriteria.ByText("FlowPricer"), InitializeOption.NoCache);
//Get list box of all region_listbox = (TestStack.White.UIItems.ListBoxItems.ListBox)((TestStack.White.UIItems.UIItemContainer)(_mainWindow)).Items[1];
// Select Europe_listbox.Select(2);//Select Europe//Get button_btnok = (TestStack.White.UIItems.Button)((TestStack.White.UIItems.UIItemContainer)(_mainWindow)).Items[5];_btnok.Click();
//Put wait for 3 sec// Thread.Sleep(1000);
//popup AddIns Region Override._mainWindow = _application.GetWindow(SearchCriteria.ByText("AddIns Region Override"), InitializeOption.NoCache);_listbox = (TestStack.White.UIItems.ListBoxItems.
ListBox)((TestStack.White.UIItems.UIItemContainer)(_mainWindow)).Items[1];_listbox.Select(2);
//Select Europe//Put wait for 3 secThread.Sleep(2000);
//Get button_btnok = (TestStack.White.UIItems.Button)((TestStack.White.UIItems.UIItemContainer)(_mainWindow)).Items[5];_btnok.Click();
}
catch (Exception ex){
}
}
static void loadingReadingMain(){
try{
//_mainWindow = _application.GetWindow(SearchCriteria.ByText("Unified Trading Desktop (EU)"), InitializeOption.NoCache);// Find Menu//var test = ((TestStack.White.UIItems.UIItemContainer)(_application));
//Loading All controls from Main Windows_allWindows=_application.GetWindows();
StringBuilder sb = new StringBuilder();
foreach (var allWindow in _allWindows){
foreach (var uiItem in allWindow.Items){
if (uiItem is TestStack.White.UIItems.UIItem){
TestStack.White.UIItems.
UIItem _uiItem = uiItem as TestStack.White.UIItems.UIItem;_totalControls.Append(GetAllControl(_uiItem));
}
//if (uiItem is TestStack.White.UIItems.Image)//{// // sb.Append(((TestStack.White.UIItems.Image)uiItem).Name.ToString());//}//if (uiItem is TestStack.White.UIItems.Thumb)//{// sb.Append(((TestStack.White.UIItems.Thumb)uiItem).Name.ToString());//}//if (uiItem is TestStack.White.UIItems.WindowStripControls.MenuBar)//{// sb.Append(((TestStack.White.UIItems.WindowStripControls.MenuBar)uiItem).Name.ToString());//}//if (uiItem is TestStack.White.UIItems.WPFLabel)//{// sb.Append(((TestStack.White.UIItems.WPFLabel)uiItem).Name.ToString());//}//if (uiItem is TestStack.White.UIItems.Custom.CustomUIItem)//{// sb.Append(((TestStack.White.UIItems.Custom.CustomUIItem)uiItem).Name.ToString());//}//if (uiItem is TestStack.White.UIItems.Button)//{// sb.Append(((TestStack.White.UIItems.Button)uiItem).Name.ToString());//}//if (uiItem is TestStack.White.UIItems.WindowStripControls.WPFStatusBar)//{// sb.Append(((TestStack.White.UIItems.WindowStripControls.WPFStatusBar)uiItem).Name.ToString());//}//if (uiItem is TestStack.White.UIItems.Panel)//{// var result1 = uiItem as TestStack.White.UIItems.Panel;// foreach (var childitem in result1.Items)// {// sb.Append(childitem.Name.ToString());// }// sb.Append(((TestStack.White.UIItems.Panel)uiItem).Name.ToString());//}}
}
string result = _totalControls.ToString();}
catch (Exception ex){
}
}
private string getName(TestStack.White.UIItems.UIItemContainer uiItem){
if (uiItem is TestStack.White.UIItems.Panel){
var panel = uiItem as TestStack.White.UIItems.Panel;
if (panel.Items.Count > 0){
foreach (var UIItem in panel.Items){
}
}
}
return "";}
private static StringBuilder GetAllControl(TestStack.White.UIItems.UIItem uiItem){
StringBuilder sbResult = new StringBuilder();
Type nodeType = uiItem.GetType();
switch (uiItem.GetType().Name){
case "Panel":
var panel = uiItem as TestStack.White.UIItems.Panel;
if (panel != null) foreach (TestStack.White.UIItems.UIItemContainer panelItem in panel.Items) sbResult.Append(GetAllControl(panelItem));
break;
case "Image":
var ImguiItem = uiItem as TestStack.White.UIItems.Image;sbResult.Append(ImguiItem.Name.ToString());
break;
case "Thumb":
var ThumbuiItem = uiItem as TestStack.White.UIItems.Thumb;sbResult.Append(ThumbuiItem.Name.ToString());
break;
case "WindowStripControls.MenuBar":
var MnuuiItem = uiItem as TestStack.White.UIItems.WindowStripControls.MenuBar;sbResult.Append(MnuuiItem.Name.ToString());
break;
case "WPFLabel":
var WPFLabeluiItem = uiItem as TestStack.White.UIItems.WPFLabel;sbResult.Append(WPFLabeluiItem.Name.ToString());
break;
case "TestStack.White.UIItems.Custom.CustomUIItem":
var CustomuiItem = uiItem as TestStack.White.UIItems.Custom.CustomUIItem;sbResult.Append(CustomuiItem.Name.ToString());
break;
case "TestStack.White.UIItems.WindowStripControls.WPFStatusBar":
var statusuiItem = uiItem as TestStack.White.UIItems.WindowStripControls.WPFStatusBar;sbResult.Append(statusuiItem.Name.ToString());
break;
}
return sbResult;}
private void GetAllControl(TestStack.White.UIItems.UIItemCollection uiItem){
foreach (TestStack.White.UIItems.UIItemContainer uicontainers in uiItem){
StringBuilder test = new StringBuilder();test.Append(GetAllControl(uicontainers));
}
}
}
}
No comments:
Post a Comment