Welcome Serena Central users! CLICK HERE
Sabrina Absent Member.
Absent Member.

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

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'");
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,

1 Reply
AndySchott Absent Member.
Absent Member.

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

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'");
Assert.AreEqual(true, formsWindow.Visible);
Assert.AreEqual(true, formsWindow.Enabled);

