iamraj09
11 years agoContributor
How to wait for a child object till it is available
Hello everyone ....I am trying to click on a button...it looks enabled but when I click it is in frozen state ....and I would get an error stating that the one of the object is not available .
My question is how can we wait till the last object is available......
Here is the code and the screenshot for the reference.
//---------------------------------------------Code Snippets-----------------------------------------------//
function Open_Existing_Project()
{
var Open_Project_Button;
var Open_Project_Window;
var OpenProject_TextBox;
var ProjectUpDownGradeWindow;
var ProjectUpdate;
var OK_Button;
var Central_StatusBar;
var Central_Menu_bar;
var Stop_Watch;
var LogicBuilder_Button;
var Logic_StatusBar;
var Central;
Central=Sys.Process("Central");
Open_Project_Button=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("headerBar").WPFObject("LayoutRoot").WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 1).WPFObject("DockPanel", "", 1).WPFObject("StackPanel", "", 1).WPFObject("Button", "Open project", 2);
Open_Project_Button.Click();
Central_Menu_bar=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("headerBar").WPFObject("LayoutRoot").WPFObject("Border", "", 1);
Open_Project_Window=Sys.Process("Central").Window("#32770", "Open project", 1).Window("DUIViewWndClassName", "", 1).UIAObject("Explorer_Pane").Window("CtrlNotifySink", "", 3).Window("SHELLDLL_DefView", "ShellView", 1).UIAObject("Items_View");
OpenProject_TextBox=Sys.Process("Central").Window("#32770", "Open project", 1).Window("ComboBoxEx32", "", 1).Window("ComboBox", "", 1).Window("Edit", "", 1);
OpenProject_TextBox.setText("30148RE-HP_F1404107.project");
Central_StatusBar=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("StatusBar", "", 1).WPFObject("StatusBarItem", "", 1).WPFObject("Rectangle", "", 1);
Open_Project_Window.Keys("~o"); // Opening the project *Note Project is too big and it take verz long time ...2-3 minutes to load completely ....
Stop_Watch=HISUtils.StopWatch;
Stop_Watch.Start(); // Staring the stop watch..........
while(!Central_Menu_bar.Enabled) // Checking whether the menu bar is enabled or not ....
{
Delay(500);
}
while(!Central_StatusBar.Enabled) // Checking whether the status bar is enabled or not ....
{
Delay(500);
}
// This is the button trying to click .....but it is in frozen state...
LogicBuilder_Button=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("headerBar").WPFObject("LayoutRoot").WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 1).WPFObject("DockPanel", "", 1).WPFObject("ScrollViewer", "", 1).WPFObject("StackPanel", "", 1).WPFObject("ItemsControl", "", 1).WPFObject("ContentPresenter", "", 1).WPFObject("SEDropDownButton", "", 1).WPFObject("StackPanel", "", 1).WPFObject("TextBlock", "Logic Builder", 1);
LogicBuilder_Button.Click(); // Trying to click the button .....
Logic_StatusBar=Sys.Process("Central").WinFormsObject("MainForm").WinFormsObject("_statusBar");
while(!Logic_StatusBar.Enabled){
Delay(100);
if(Logic_StatusBar.Enabled){
while(Logic_StatusBar.wPartCount==4)
{
Log.Message("If Part count is four "+Logic_StatusBar.wPartCount.toString());
Delay(100);
}
}
}
Delay(100);
Stop_Watch.Stop();
var Time=Stop_Watch.toString();
Stop_Watch.Reset();
Log.Message("Time take to open the project is "+Time);
}
My question is how can we wait till the last object is available......
Here is the code and the screenshot for the reference.
//---------------------------------------------Code Snippets-----------------------------------------------//
function Open_Existing_Project()
{
var Open_Project_Button;
var Open_Project_Window;
var OpenProject_TextBox;
var ProjectUpDownGradeWindow;
var ProjectUpdate;
var OK_Button;
var Central_StatusBar;
var Central_Menu_bar;
var Stop_Watch;
var LogicBuilder_Button;
var Logic_StatusBar;
var Central;
Central=Sys.Process("Central");
Open_Project_Button=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("headerBar").WPFObject("LayoutRoot").WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 1).WPFObject("DockPanel", "", 1).WPFObject("StackPanel", "", 1).WPFObject("Button", "Open project", 2);
Open_Project_Button.Click();
Central_Menu_bar=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("headerBar").WPFObject("LayoutRoot").WPFObject("Border", "", 1);
Open_Project_Window=Sys.Process("Central").Window("#32770", "Open project", 1).Window("DUIViewWndClassName", "", 1).UIAObject("Explorer_Pane").Window("CtrlNotifySink", "", 3).Window("SHELLDLL_DefView", "ShellView", 1).UIAObject("Items_View");
OpenProject_TextBox=Sys.Process("Central").Window("#32770", "Open project", 1).Window("ComboBoxEx32", "", 1).Window("ComboBox", "", 1).Window("Edit", "", 1);
OpenProject_TextBox.setText("30148RE-HP_F1404107.project");
Central_StatusBar=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("StatusBar", "", 1).WPFObject("StatusBarItem", "", 1).WPFObject("Rectangle", "", 1);
Open_Project_Window.Keys("~o"); // Opening the project *Note Project is too big and it take verz long time ...2-3 minutes to load completely ....
Stop_Watch=HISUtils.StopWatch;
Stop_Watch.Start(); // Staring the stop watch..........
while(!Central_Menu_bar.Enabled) // Checking whether the menu bar is enabled or not ....
{
Delay(500);
}
while(!Central_StatusBar.Enabled) // Checking whether the status bar is enabled or not ....
{
Delay(500);
}
// This is the button trying to click .....but it is in frozen state...
LogicBuilder_Button=Sys.Process("Central").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("LayoutRoot").WPFObject("headerBar").WPFObject("LayoutRoot").WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 1).WPFObject("DockPanel", "", 1).WPFObject("ScrollViewer", "", 1).WPFObject("StackPanel", "", 1).WPFObject("ItemsControl", "", 1).WPFObject("ContentPresenter", "", 1).WPFObject("SEDropDownButton", "", 1).WPFObject("StackPanel", "", 1).WPFObject("TextBlock", "Logic Builder", 1);
LogicBuilder_Button.Click(); // Trying to click the button .....
Logic_StatusBar=Sys.Process("Central").WinFormsObject("MainForm").WinFormsObject("_statusBar");
while(!Logic_StatusBar.Enabled){
Delay(100);
if(Logic_StatusBar.Enabled){
while(Logic_StatusBar.wPartCount==4)
{
Log.Message("If Part count is four "+Logic_StatusBar.wPartCount.toString());
Delay(100);
}
}
}
Delay(100);
Stop_Watch.Stop();
var Time=Stop_Watch.toString();
Stop_Watch.Reset();
Log.Message("Time take to open the project is "+Time);
}