Unable to Click a button or Fill text box in a window using Test Stack

72 Views Asked by At

When I Inspect a button in the window, below properties are listed with FrameworkId="InternetExplorer". How can I automate the button click or textbox fill by using Teststack.white?

This is what the inspector shows:

Mouse move (865,608)
hwnd=0x00250DD6 64bit 
class="Internet Explorer_Server" 
style=0x56000000 
ex=0x0
RuntimeId:  "[42.2428374.3.3538]"
BoundingRectangle:  {l:743 t:599 r:1176 b:689}
ProcessId:  464
ControlType:    UIA_ButtonControlTypeId (0xC350)
LocalizedControlType:   "button"
Name:   "Use another account"
AccessKey:  ""
HasKeyboardFocus:   false
IsKeyboardFocusable:    false
IsEnabled:  true
AutomationId:   "otherTile"
HelpText:   ""
IsPassword: false
IsOffscreen:    false
Orientation:    0
FrameworkId:    "InternetExplorer"
IsRequiredForForm:  false
AriaRole:   "button"
2

There are 2 best solutions below

0
On

Your component is a button, so you can use this method from TestStack:

var btn = currentWindow.Get<Button>(SearchCriteria.ByAutomationId("otherTile");
// Perform click
btn.Click();

You can use the same method for textbox and set the value of Text property of TextBox directly.

0
On

Well, I was able to achieve this using the below code, since this button is not a windows button we need to explictly mention the Framework:

window.Get<Button>(SearchCriteria.ByAutomationId("otherTile").AndOfFramework(WindowsFramework.InternetExplorer)).Click();