Forum Discussion
11 Replies
- rraghvani
Champion Level 3
- rraghvani
Champion 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-ngcOccasional Contributor
Isn't that a web app? My AUT is Java, so does not seem like a representative test
- cg-ngcOccasional 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
- rraghvani
Champion 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,
Main window visible and Child window visibleMain window visible and Child window invisibleNotice 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!