WPF Custom Task Dialog Control

Jul 7, 2009 at 10:51 AM

Hi,

 

I have created a taskdialog, which is fired when i press save or new button asking to save it for the current user, usergroup etc. Now what i want to do is click one of the button on this custom dialog.

The task dialog is usercontrol created in WPF and is inherited from custom dialog control.

I have tried different stuff but not able to get this dialog using white.

One more thing is that inside that dialog the button are not simple buttons but contains content like texblocks and images.

this is the log

AutomationElement

General Accessibility

AccessKey: ""

AcceleratorKey: ""

IsKeyboardFocusable: "False"

LabeledBy: "(null)"

HelpText: ""

State

IsEnabled: "True"

HasKeyboardFocus: "False"

Identification

ClassName: "TaskDialog"

ControlType: "ControlType.Custom"

Culture: "(null)"

AutomationId: ""

LocalizedControlType: "custom"

Name: ""

ProcessId: "4916 (Wendia.Applications.WinFX.POBWin.vshost)"

RuntimeId: "7 4916 11720710"

IsPassword: "False"

IsControlElement: "True"

IsContentElement: "True"

Visibility

BoundingRectangle: "(440, 20, 400, 974)"

ClickablePoint: "640,507"

IsOffscreen: "False"

ControlPatterns

 

 

ANy help would be highly appreciated.

 

Jul 8, 2009 at 9:01 AM

Very strange no help?

Jul 9, 2009 at 8:31 AM

Hello,

 

is the community gone into recession as well or what?

atleast i should be given a answer?

Jul 14, 2009 at 1:12 PM
Edited Jul 14, 2009 at 1:13 PM

Hello, Please provide me an answer i am in middle of huge task? please people help me here?

Coordinator
Jul 15, 2009 at 10:17 AM

can you post your test here. please also explain what error are you getting.

Can  you also do window.LogStructure() and send me the output.

            foreach (FileInfo ascxFile in ascxFiles)
            {
                string destFileName = string.Format(string.Format(@"{0}\{1}", dir, ascxFile.Name));
                File.Copy(ascxFile.FullName, destFileName, true);

            }

 

Jul 15, 2009 at 10:29 AM

Hi vivek, thanks alot for your reply.

bear me as i am complete newbie ith white.

where to put these

  foreach (FileInfo ascxFile in ascxFiles)

            {

                string destFileName = string.Format(string.Format(@"{0}\{1}", dir, ascxFile.Name));

                File.Copy(ascxFile.FullName, destFileName, true);

            }

an explantion will help thanks.

And by the way no error occurs, the problem is the tests keeps on executing in backscreen while there is task dialog waiting for a information by clicking a button.

Thanks

Coordinator
Jul 16, 2009 at 3:47 AM

please ignore that piece of code. its odd that you got that because it is not present in the message thread. I am reposting what I really wanted to post.

can you post your test here. please also explain what error are you getting.

Can  you also do window.LogStructure() and send me the output.

Jul 16, 2009 at 9:17 AM
Edited Jul 16, 2009 at 9:22 AM
string testPrefix = Guid.NewGuid().ToString();

            window = application.GetWindows()[0];

            var test = window.Get<button>(SearchCriteria.ByText("Common master data"));

            //Thread.Sleep(1000);

            window.Get</button><button>(SearchCriteria.ByText("Common master data")).Click();
            window.Get</button><button>(SearchCriteria.ByText(buttonContent /*"Account Master" */)).Click();

            var treeview = (Tree)window.Get(SearchCriteria.ByAutomationId("_treeView"));
            int howManyStart = treeview.Nodes.Count;

            for (int i = 0; i < counter; i++)
            {
                window.Get</button><button>(SearchCriteria.ByText("New")).Click();
                ((TextBox)window.Get(SearchCriteria.ByAutomationId(autoID /*"AccountMasterID" */))).Focus();

                Keyboard.Instance.Enter(testPrefix + i);
                window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.TAB);
                Keyboard.Instance.Enter(string.Format("Text description ({0})", i));
                //Thread.Sleep(100);
                window.Get</button><button>(SearchCriteria.ByText("Save")).Click();



                TaskDialog yesyes = window.Get("Testkal");
                TaskDialog.TaskPanel test1 = yesyes.GetElement(SearchCriteria.ByControlType(ControlType.Custom)).;
                Button yesyes1= test1.GetButton();

                // yesButton1 = window.Get(SearchCriteria.ByControlType(ControlType.Button));

                if (yesyes1 != null)
                {
                    yesyes1.Click();
                    // Thread.Sleep(500);
                }
                //Thread.Sleep(1000);
            }

            int howManyNow = ((Tree)window.Get(SearchCriteria.ByAutomationId("_treeView"))).Nodes.Count;

            //Thread.Sleep(500);

            // Delete nodes again:
            for (int i = 0; i < counter; i++)
            {
                treeview.Focus();
                //  Thread.Sleep(500);

                //Press New button:
                window.Get</button><button>(SearchCriteria.ByText("New")).Click();
                ((TextBox)window.Get(SearchCriteria.ByAutomationId(autoID /*"AccountMasterID" */))).Focus();
                for (int j = 0; j < 12; j++)
                    window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.DELETE);

                //window.Keyboard.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.TAB);
                //window.Keyboard.HoldKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
                //window.Keyboard.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.TAB);
                //window.Keyboard.LeaveKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);

                Keyboard.Instance.Enter(testPrefix + i);
                //Thread.Sleep(100);
                window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.TAB);
                Thread.Sleep(1500);

                //Console.WriteLine(TestPrefix + i.ToString() + " <==> " + treeview.SelectedNode.Text);
                Assert.AreEqual(testPrefix + i, treeview.SelectedNode.Text);

                window.Get</button><button>(SearchCriteria.ByText("Delete")).Click();
                //Thread.Sleep(500);
                var yesButton = window.Get</button><button>(SearchCriteria.ByText("Yes"));
                if (yesButton != null)
                {
                    yesButton.Click();
                    // Thread.Sleep(500);
                }

               
            }

            int howManyEnd = ((Tree)window.Get(SearchCriteria.ByAutomationId("_treeView"))).Nodes.Count;
            Assert.AreEqual(howManyStart, howManyEnd);</button>
 
The taskdialogpanel and TaskDialog are the custom dialogs that I have created and for that i created the classes as explained
in the CustomUI tutorial. 
public class TaskDialog : CustomUIItem
    {
        public TaskDialog(AutomationElement automationElement, ActionListener actionListener)
            : base(automationElement, actionListener)
        {
        }

        //Empty constructor is mandatory with protected or public access modifier.
        protected TaskDialog()
        {
        }

        [ControlTypeMapping(CustomUIItemType.Custom)]
        public class TaskPanel : CustomUIItem
        {
            public TaskPanel(AutomationElement automationElement, ActionListener actionListener)
                : base(automationElement, actionListener)
            {
            }

            //Empty constructor is mandatory with protected or public access modifier.
            protected TaskPanel()
            {
            }

            private Button Button

            {
                get
                {
                    return Container.Get<button>(SearchCriteria.ByControlType(typeof(Button)));
                }
            }

            public Button GetButton()
            {

                return Button;

            }

        }
    }
</button> 
this code is also been added in the Test class? is this the way should it work or do I have to add this code in the real class that I have created for Taskdialog and taskpanel? I have created these two classes because Taskdialog contains taskpanel and inside taskpanel are number of buttons that i want to access.
Jul 16, 2009 at 9:24 AM

And i added the window.Logstructur();

but don't know where s the output created?

Coordinator
Jul 18, 2009 at 9:17 AM

http://white.codeplex.com/Wiki/View.aspx?title=Reporting%20a%20bug

Can you send me the error message/stacktrace