Forum Discussion
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
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!
- cg-ngc3 months agoOccasional Contributor
TC version is 15.65.12.6 x64
Looking at your screenshots, I guess what you are showing is the "Time Diff" column? Showing that there is no wait?
function debugme(){ Log.Message("Start"); var cf = Aliases.javaw.WaitAliasChild("Child_Frame"); Log.Message("Checking exists"); let w = cf.Exists Log.Message("Finish"); }
As you can see, when it's not visible, it waits 10 seconds
Related Content
- 4 months ago
- 2 years ago
Recent Discussions
- 18 hours ago