An Kumar
An Kumar

Reputation: 77

How to get Textbox background color in TestStack.White

              I am using TestStack.White for automation testing of my WPF code. I am trying to get the background color of one of my textbox's. I tried to use NativeWindow to get the background color but it is not giving me the currect color code. Is there anything wrong in my code or Is there any other way I can do that?

Application application = null; Window window = null; application = Application.Launch( @"C:\New folder\WPFTRaining\Automation.TimelineUI\Automation.TimelineUI\bin\Debug\Automation.TimelineUI.exe");

        var windows = application.GetWindows();
        window = windows.Find(x => x.Id == "Form1");


        TextBox age = window.Get<TextBox>(SearchCriteria.ByAutomationId("TextBoxAGE"));
        age.Enter("90");

        Button saveButton = window.Get<Button>("SaveButton");
        saveButton.Click();
        Thread.Sleep(5000);

        var nativeWindow = new NativeWindow(new IntPtr(window.Get<TextBox>("TextBoxAGE").AutomationElement.Current.NativeWindowHandle));
        Assert.AreEqual(nativeWindow.BackgroundColor,"#FF0000");                 

Upvotes: 0

Views: 452

Answers (0)

Related Questions