Window class

Jul 19, 2011 at 9:44 AM

Hi All!

Regarding this code:

    Application application = Application.Launch("foo.exe"); 
   
Window window = application.GetWindow("bar", InitializeOption.NoCache); 
 
   
Button button = window.Get<Button>("save"); 
   button
.Click(); 

Wich class i should include to usw Window and Button.

I found only Application in  White.Core.


Regards.

Jul 19, 2011 at 10:04 AM
Edited Jul 19, 2011 at 10:06 AM

 

using White.Core.UIItems;

using White.Core.UIItems.WindowItems; 
Intellicence should show you these usings if White.Core is added as Reference
Has you added White.Core.dll as Reference to your Project?
Application can be found in other namespaces too
Throndorin
Jul 19, 2011 at 11:39 AM

Throndorin Thank you very much!

Please help me with one more issue:

private void button1_Click(object sender, EventArgs e)
        {
            White.Core.Application app = White.Core.Application.Launch(appath);


           Window window = app.GetWindow("MCP2200 Configuration Utility", InitializeOption.NoCache);


            White.Core.UIItems.Button button = window.Get<White.Core.UIItems.Button>("Configure");   

            button.Click();   //here i get exeption
       }

I get exeption - Object reference not set to an instance of an object.

Thank you.

Jul 19, 2011 at 12:04 PM

I got it right:

This way it's work

 

White.Core.Application app = White.Core.Application.Launch(appath); 
 Window window = app.GetWindow("MCP2200 Configuration Utility", InitializeOption.NoCache)

White.Core.UIItems.Button button = window.Get<White.Core.UIItems.Button>(SearchCriteria.ByText("Update VID/PID"));  

button.Click();

Now i need to write some data in text boxes on the form

  White.Core.UIItems.TextBox text1 = window.Get<White.Core.UIItems.TextBox>("Vandor ID");
  text1.Text = "ABCD";

I get exeption - Object reference not set to an instance of an object.

White.Core.UIItems.TextBox text1 = window.Get<White.Core.UIItems.TextBox>(SearchCriteria.ByText("Vandor ID"));
  text1.Text = "ABCD";

I get exeption - A QueryInterface call was made requesting the class interface of COM visible managed class 'MS.Internal.AutomationProxies.WindowsEditBox'. However since this class derives from non COM visible class 'MS.Internal.AutomationProxies.ProxyHwnd', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.

Jul 19, 2011 at 12:11 PM

Hi

 

first to get stable tests which told you the problems use Asserts to find out that needed Elements like Buttons and so on, after Getting them from parent element are not Null.

 

in your case It seems that text1 is null and so "Object reference not set to an instance of an object"

 

I prefer getting elements by using SearchCriteria.ByAutomationID. First have a look with UISpy or UIAVerify which elements are visible for UIAutomation and so for White.

 

to write Text use text1.BuktText = "ABCD" instead of text1.Text (Text is better for read) or use text1.Enter ("ABCD") to change value.

 

Throndorin

Jul 19, 2011 at 1:42 PM

Hi Throndorin

 TextBox text1 = window.Get<TextBox>(SearchCriteria.ByAutomationId("Vendor ID"));

text1.BulkText = "ABCD";
// or text1.Enter("ABCD");

compiles ok, but as i see in debug mode  text1 = null. looks like Get function doesn't find the text box control. what could be  a problem?

thanks.

Jul 19, 2011 at 1:44 PM
Edited Jul 19, 2011 at 1:45 PM

Does UISpy see the TextBox?

 

Try

 

AutomationElement element = window.GetElement(SearchCriteria.ByAutomationId("Vendor ID"));

 

is element also null?

Jul 19, 2011 at 2:10 PM
Edited Jul 19, 2011 at 2:10 PM

where can i find AutomationElement?

Jul 19, 2011 at 2:21 PM

You need to reference

UIAutomationClient

UIAutomationClientsideProviders

UIAutomationProvider

UIAutomationTypes

They are part of .Net

using System.Windows.Automation;

 

Throndorin

Jul 19, 2011 at 2:32 PM

using System.Windows.Automation;
 Provides support for Windows Presentation Foundation (WPF) UI Automation clients.

I'm working with Windows Form Aplication

Jul 19, 2011 at 2:36 PM

Windows Form should work too

Jul 19, 2011 at 2:45 PM
Edited Jul 19, 2011 at 2:47 PM

right! i've managed to include using System.Windows.Automation;

AutomationElement element = window.GetElement(SearchCriteria.ByAutomationId("Product"));
 White.Core.UIItems.TextBox box = new White.Core.UIItems.TextBox(element, window.ActionListener);

  box.BulkText = "abcd";

now i get exeption: A QueryInterface call was made requesting the class interface of COM visible managed class 'MS.Internal.AutomationProxies.WindowsEditBox'. However since this class derives from non COM visible class 'MS.Internal.AutomationProxies.ProxyHwnd', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.

Jul 19, 2011 at 3:02 PM

Well... I think i understand what's the problem - i search a text box by a label attached to it , but it isn't the actual name of the text box.

If i don't know the real name of text box - how can i find it , may be by index?

Jul 19, 2011 at 3:46 PM

what information does UISpy or UIAVerify show for the Textbox?

are there other Textboxes in the same parent?

Jul 19, 2011 at 3:51 PM

i have several Text Boxes.

Two of them i found:

White.Core.UIItems.TextBox text1 = window.Get<White.Core.UIItems.TextBox>(SearchCriteria.ByAutomationId("tbIODefault"));
White.Core.UIItems.TextBox text2 = window.Get<White.Core.UIItems.TextBox>(SearchCriteria.ByAutomationId("tbIOConfig"));

text1.Enter("ABCD");
text2.Enter("EFGH");

works fine. but other i dont know its name or id. what is  UISpy and  UIAVerify? how can i use it?

Jul 19, 2011 at 3:58 PM

UIAVerify can be found on codeplex.

 

UISpy is part of a Microsoft SDK

 

These Tools shows Information about UIElements like AutomationID, Controltype, and so on

Jul 19, 2011 at 3:59 PM

UIAVerify can be found on codeplex.

 

UISpy is part of a Microsoft SDK

 

These Tools shows Information about UIElements like AutomationID, Controltype, and so on