Capturing text from a Textbox

Aug 3, 2009 at 3:23 PM

Hi,

I am new to White and trying automate Calculator. I am not able to verify the result due to following issues

1. Not able to find Id (Caption) for the text box present in the Calculator.

I am using Spy++ for finding the UI Elements. Below is the code i am using

Application application = Application.Launch(@"C:\WINDOWS\system32\calc.exe");
            Window window = application.GetWindow("Calculator", InitializeOption.NoCache);
            Button one = window.Get<Button>("1");
            one.Click();
            Button plus = window.Get<Button>("+");
            plus.Click();
            Button two = window.Get<Button>("2");
            two.Click();
            Button equal = window.Get<Button>("=");
            equal.Click();
            TextBox result = window.Get<TextBox>(" "); // what should i put in the bracket so that it can be identified.
            Assert.AreEqual("3", result.Text);

Thanks,

CybMS

 

Coordinator
Aug 4, 2009 at 3:33 AM

 

            TextBox result = window.Get<TextBox>(SearchCriteria.ByAutomationId("403")); // what should i put in the bracket so that it can be identified.
            Assert.AreEqual("3.  ", result.Text);

TextBox result = window.Get<TextBox>(SearchCriteria.ByAutomationId("403"));

TextBox result = window.Get<TextBox>("");

you can try anyone of above.

 

Aug 4, 2009 at 6:55 AM

Thanks Vivek. It worked.

But can you tell me how did u get the AutomationId=403. As i am uinsg Spy++ to identify the captions and dont see anything like Automationid in it.

Thanks,

CybMS

 

Aug 4, 2009 at 7:34 AM

Hi I'm not sure but Spy++ is not UI Spy.

As I can see Spy++ does not now anything about UIAutomation so it does not recognice the automation ID

Try UI Spy (as Part of the Mircosoft SDK) or easier

AutomationVerify 

 

Throndorin