WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.17' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714489653.8050489425659179687500', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
I played a lot with Coded UI Tests API on WPF applications these last weeks. <\/p>\n
It turned out that this is a really powerful framework available to use but that we need to write a lot of code ourselves even for simple things. <\/p>\n
You may already know the coded ui test utilities of Gautam Goenka available on his blog<\/a>. <\/p>\n On this blog post, I want to introduce a set of complementary helper methods that you can use in your project.<\/strong> The links to the binaries\/sources are at the end of the post.<\/p>\n Here is a list of the available features :<\/strong><\/p>\n <\/p>\n It’s always useful to know if a listbox is empty or not. Now you can use these simple methods. \/\/Tell me if you are empty my dear <\/p>\n Sometimes you store information trough AutomationIds. This method will help you to retrive them in a simple way. \/\/Rertrieve the ids <\/p>\n This is a recursive method which can helps you in several scenarii. Be sure to notice that there is an override which takes a boolean as a parameter. If it sets to false, the method will return ALL the children and not only the direct one.<\/p>\n Also, be sure to understand that you won’t be able to call the Find method on these controls as they do not have defined search properties.<\/strong><\/p>\n [csharp] \/\/Get only the direct children foreach(WpfEdit edit in children) SomethingCool();<\/p>\n \/\/Get all the children in the tree below the control foreach(WpfEdit edit in children) SomethingCoolToo(); <\/p>\n I found out trying to set the text of a TextBox that you can end up waiting eternity for the text being really set.<\/strong><\/p>\n I do so tried to create an helper method which can be faster using the automation pattern. I then try to use the value pattern but oddly, it wasn’t available on the TextBox automation peer. <\/p>\n I finally find on a MSDN code sample comments that<\/a> “Elements that support TextPattern do not support ValuePattern and TextPattern does not support setting the text of multi-line edit or document controls”. So if the control implements the TextPattern, you have to use a fallback method which is in fact simulate keyboard inputs. <\/strong><\/p>\n The helper method just do that :<\/p>\n [csharp] \/\/Set the text <\/p>\n Testing if a control implements a pattern and then trying to call it represents a lot of code line. \/\/Set the value <\/p>\n Same as the previous, one single line to collapse\/expand a control. If the control does not implements the pattern, the method will just returns false. \/\/Expanding \/\/Collapsing <\/p>\n Select a control in one line of code ! \/\/Select the control <\/p>\n Instead of simulate a mouse click, you can now use this method which will use the invoke pattern even if the control is hided. \/\/Invoke <\/p>\n The binaries and the, well commented, soure code can be found at this adress : https:\/\/www.dropbox.com\/s\/gmpybsviirm3bqd#view:list<\/a><\/p>\n\n
Features, code sample and comments<\/h4>\n
List, Tree and Menu emptiness tests as User extension methods<\/h5>\n
\n[csharp]
\n\/\/ WpfTree treeView = … ;<\/p>\n
\nbool isEmpty = treeView.IsEmpty();
\nAssert.IsTrue(isEmpty);
\n[\/csharp]<\/p>\nHelper to get all the AutomationIds of a control children<\/h5>\n
\n[csharp]
\n\/\/ WpfControl control= … ;<\/p>\n
\nList<string> idsOfChildren = control.GetChildrenAutomationIds();
\n[\/csharp]<\/p>\nHelper to get all the children control of a specific type<\/h5>\n
\n\/\/ WpfControl control= … ;<\/p>\n
\nList<WpfEdit> children= control.GetChildren<WpfEdit>();<\/p>\n
\nList<WpfEdit> children= control.GetChildren<WpfEdit>(onlyDirectChildren: false);<\/p>\n
\n[\/csharp]<\/p>\nEasier set text syntax with fallback method: youpi !<\/h5>\n
\n\/\/WpfControl control = …;<\/p>\n
\nbool isTextSet= control.TrySetText("I love Coded UI tests");
\nAssert.IsTrue(isTextSet);
\n[\/csharp]<\/p>\nEasier set value syntax<\/h5>\n
\nWith this helper you just have one single line method call.
\n[csharp]
\n\/\/WpfControl control = …;<\/p>\n
\nbool isValueSet= control.TrySetValue("I want to set this value.");
\nAssert.IsTrue(isValueSet);
\n[\/csharp]<\/p>\nEasier expand and collapse syntax<\/h5>\n
\n[csharp]
\n\/\/WpfControl control = …;<\/p>\n
\nbool isExanpded = control.TryExpand();
\nAssert.IsTrue(isExanpded);<\/p>\n
\nbool isCollapsed = control.TryCollapse();
\nAssert.IsTrue(isCollapsed);
\n[\/csharp]<\/p>\nEasier selection syntax<\/h5>\n
\n[csharp]
\n\/\/WpfControl control = …;<\/p>\n
\nbool isSelected = control.TrySelect();
\nAssert.IsTrue(isSelected);
\n[\/csharp]<\/p>\nEasier Invoke syntax<\/h5>\n
\n[csharp]
\n\/\/WpfControl control = …;<\/p>\n
\nbool isInvoked = control.TryInvoke();
\nAssert.IsTrue(isInvoked);
\n[\/csharp]<\/p>\nWere are the binaries ?<\/h4>\n