Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Sabrina Absent Member.
Absent Member.
223 views

Silk4Net FormsWindow fails to find an known FormsWindow Object in Silk test Version 17.0.0.8241


How to enable a visible object when an already located object in the application under test gets invisible during record and replay
I have stepped through the Silk4Net code using the
debugger and I can see that the program puts more than 10mn to find the located object and some times it fails because it cannot find the located object. I added a Verify propeties of the TestObject and I found the following result:


Assert.AreEqual(false, formsWindow.Visible);
Assert.AreEqual(true, formsWindow.Enabled);
As you can see: formsWindow.Visible = False even if the formsWindow is displayed.


Note : I use the Locator Path instead of the Object Map:

public static readonly Desktop _desktop = Agent.Desktop;
RemoteAgent agent1 = Agent.Connect("My PC");
FormsWindow formsWindowFrmSampleApplication = agent1.Desktop.FormsWindow("@automationId='frmSampleApplication'");
formsWindowFrmSampleApplication.SetFocus();
formsWindowFrmSampleApplication.SetActive();
FormsWindow FormSampleApp = desktop.< FormsWindow > find("/FormsWindow[@caption='Windows Forms Sample Application']");

Can someone advise why the formsWindow.Visible property is always set to false? And what can I do to make this object visible?

Thank you,

0 Likes
1 Reply
AndySchott Absent Member.
Absent Member.

RE: Silk4Net FormsWindow fails to find an known FormsWindow Object in Silk test Version 17.0.0.8241

The problem is that you're using calls from two different Agents.

The first line of your sample code returns a reference to the Desktop class for the local agent running on your PC.

The second line of your sample code connects to an agent that is running on the PC named "My PC". Even if this resolves to your current PC, it will create a separate agent from the one used on the first line of the code.

The code then proceeds to use the second agent to try to find the main window of the application under test. You didn't post the contents of your TestInitialize method, but the generated code for that method runs the configured BaseState using the local agent. If you haven't ran the BaseState using the second agent, it hasn't hooked your application and won't be able to find the main window.

Assuming you're not doing anything special with testing of applications on other PC's, you should be able to do everything using the default agent running on the local machine.  Something similar to this:

public static readonly Desktop _desktop = Agent.Desktop;
FormsWindow formsWindowFrmSampleApplication = _desktop.FormsWindow("@automationId='frmSampleApplication'");
formsWindowFrmSampleApplication.SetFocus();
formsWindowFrmSampleApplication.SetActive();
Assert.AreEqual(true, formsWindow.Visible);
Assert.AreEqual(true, formsWindow.Enabled);

Andy

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.