Forum Discussion
I'm not sure what version of TC you are using. Since WaitTime is 0, WaitAliasChild will return immediately. Assuming the child alias object exists, then the property Visible will return a value immediately too.
However, if the child alias object does not exist, WaitAliasChild will return a stub object immediately. Property Exists will return immediately, but Visible will return an error after a number of seconds - depending on the project auto-wait timeout.
Ideally, you should enclose your Visible property within an If statement
let ac = Aliases.ICS.WaitAliasChild("AddChannelWindwo", 0);
if (ac.Exists) {
let ac_vis = ac.Visible;
}
WaitAliasChild does indeed always return immediately.
Your statement "Property Exists will return immediately" is, however, incorrect (At least in my case)
It will ONLY return immediately if the element is visible.
If it's invisible, it will wait for the default timeout
WRT the enclosing of an if statement - yeah, in production code, I would indeed do that. For the sample code, however, I KNEW whether it would return true or false, I just did it that way to keep the sample code shorter
- rraghvani3 months agoChampion Level 3
Have you looked into https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/how-to/refresh-cache.html ?
- rraghvani3 months agoChampion Level 3
Using TC v15.55.53.7, here's a small example based on the website https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_style_visibility
It returns immediately
- cg-ngc3 months agoOccasional Contributor
Isn't that a web app? My AUT is Java, so does not seem like a representative test
- cg-ngc3 months agoOccasional Contributor
RefreshMappingInfo() makes it worse. It causes the waitAliasChild() to wait as well.
Here is proof that the issue is nothing to do with a quirk of the AUT.
Example Java App:
package com.example; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class App extends JPanel implements ActionListener { private static JFrame childFrame; private static boolean secondFrameVisible = false; public App() { childFrame = new JFrame("Child Window"); childFrame.setName("Child Frame"); JLabel childLabel = new JLabel("This is a child frame"); childLabel.setPreferredSize(new Dimension(400, 400)); childFrame.getContentPane().add(childLabel); childFrame.pack(); toggleSecondFrameVisibility(); JButton toggleButton = new JButton("Toggle visibility"); toggleButton.setActionCommand("vis"); toggleButton.addActionListener(this); add(toggleButton); } private static void createAndShowGUI() { JFrame frame = new JFrame("FrameDemo"); frame.setName("Main Frame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new App()); frame.pack(); frame.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { toggleSecondFrameVisibility(); } private static void toggleSecondFrameVisibility(){ secondFrameVisible = !secondFrameVisible; childFrame.setVisible(secondFrameVisible); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } }
It looks like this - a main window ("FrameDemo") with a child window ("Child Window").
When you click the "Toggle Visibility" button in the main window, the Child Window is set to invisible.Then create a Javascript project in TestComplete, add the following code to script Unit1:
function debugme(){ Aliases.javaw.WaitAliasChild("Child_Frame").Exists; // <-- set breakpoint here Aliases.javaw.WaitAliasChild("Child_Frame").Exists; // <-- set breakpoint here Aliases.javaw.WaitAliasChild("Child_Frame").Exists; // <-- set breakpoint here Aliases.javaw.WaitAliasChild("Child_Frame").Exists; // <-- set breakpoint here }
- Run the sample Java app
- Put a breakpoint on line 2 in the TestComplete IDE (The .Exists line)
- Right click the function -> run this routine
- F10 to step - no wait
- Click the "Toggle Visibility" button in the sample app to hide the child frame
- F10 to step - WAITS!!
- Click the "Toggle Visibility" button in the sample app to show the child frame
- F10 to step - no wait
- rraghvani3 months agoChampion Level 3
I'm not able to reproduce your issue. If I run the following code against a new project,
function main() { Log.Message("Start"); var mf = Aliases.java.WaitAliasChild("Main_Frame") if (mf.Exists) { Log.Message(mf.Exists); Log.Message(mf.Visible); } var cf = Aliases.java.WaitAliasChild("Child_Frame"); if (cf.Exists) { Log.Message(cf.Exists); Log.Message(cf.Visible); } Log.Message("Finish"); }
the following output is shown,
Notice the time differences, it's not waiting X number of seconds.
What version of TC are you using?
By the way, your instructions were perfect. Thanks!
Related Content
- 4 months ago
- 2 years ago
Recent Discussions
- 23 hours ago