Skip to content

How can I do click Windows form MessageBox ok button #255

@maoyuan456

Description

@maoyuan456

When I test a pop up which type is ControlType.Window and acctually it's MessageBox from:

MessageBox.Show(message, caption,
                                 MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question);

Now I want press the Yes button, but cannot capture button yes and then I tried use enter kyboard as below code, tab input is works fine but enter input not working.

var AddRemoveFlagsForm = uiHelper.FindUIElement(null, "MessageBoxDialog");
var window = AddRemoveFlagsForm.AsWindow();
window.SetForeground();
TestingWait.ForSecond(5, "Wait for continue button");
Keyboard.Press(VirtualKeyShort.TAB);
TestingWait.ForSecond(5, "Wait for continue button");
Keyboard.Press(VirtualKeyShort.TAB);
TestingWait.ForSecond(5, "Wait for continue button");
Keyboard.Press(VirtualKeyShort.ENTER);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions