WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.57' for table 'wp_options']
INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714854491.0593810081481933593750', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)


Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372
{"id":806,"date":"2011-11-09T17:16:59","date_gmt":"2011-11-09T16:16:59","guid":{"rendered":"http:\/\/www.jonathanantoine.com\/?p=806"},"modified":"2011-11-09T17:17:11","modified_gmt":"2011-11-09T16:17:11","slug":"coded-ui-tests-my-textblock-is-not-found-how-to-find-it","status":"publish","type":"post","link":"http:\/\/www.jonathanantoine.com\/2011\/11\/09\/coded-ui-tests-my-textblock-is-not-found-how-to-find-it\/","title":{"rendered":"Coded UI tests : my TextBlock is not found, how to find it ?"},"content":{"rendered":"

\"\"<\/a>In the previous post<\/a>, we have seen that setting the AutomationId can greatly help us when we want to perform some UI Tests.<\/p>\n

Todyay, I struggled with a problem which seems common after some digging on the net : the TextBlock control is not found and no assertion can be set on it.
\nBut it does not always occur and it is then difficult to debug this strange behavior.<\/strong><\/p>\n

In this post we’ll see why this happen and how to solve this issue.
\n<\/p>\n

Why and When ?<\/h3>\n

The problem comes from the TextBlockAutomationPeer. If you digg into its code you can find this :
\n[csharp]override protected bool IsControlElementCore()
\n{
\n return ((TextBlock)Owner).TemplatedParent == null;
\n} [\/csharp]<\/p>\n

This basically means that if the TextBlock is inside a template, any kind of template, it is not exposed.<\/strong>
\nFor example, if in an ItemsControl, a Listbox or another control, you use a DataTemplate containing a TextBlock, this one won’t be find by the automation client. Here is a code example :
\n[xml]<Grid>
\n <Grid.Resources>
\n <DataTemplate x:Key="ItemTemplate">
\n <TextBlock Text="{Binding }" \/>
\n <\/DataTemplate>
\n <\/Grid.Resources>
\n <ListBox ItemsSource="{Binding }"
\n ItemTemplate="{StaticResource ItemTemplate}" \/>
\n<\/Grid>[\/xml]<\/p>\n

A solution<\/h3>\n

The only dirty solution I find is to create your own TextBlock control with its own corrected AutomationPeer. <\/strong>
\nIt will be based on the original TextBlockAutomationPeer but the IsControlElementCore method will always return true.
\nAs a bonus, I let commented a snippet which will expose the TextBlock only if an AutomationId is set on it.<\/p>\n

The code to write is really light. The real issue is that you have to update every TextBlock usage in the XAML of your application.
\n[csharp]
\npublic class AutomatisableTextBlock : TextBlock
\n{
\n protected override AutomationPeer OnCreateAutomationPeer()
\n {
\n return new AlwaysVisibleTextBlockAutomationPeer(this);
\n }
\n}<\/p>\n

\/\/The corrected AutomationPeer is based on the TextBlockAutomationPeer
\npublic class AlwaysVisibleTextBlockAutomationPeer : TextBlockAutomationPeer
\n{
\n public AlwaysVisibleTextBlockAutomationPeer(TextBlock t)
\n : base(t) { }<\/p>\n

protected override bool IsControlElementCore()
\n {
\n \/\/if (String.IsNullOrEmpty(GetAutomationId()))
\n \/\/ return false;
\n return true;
\n }
\n}
\n[\/csharp]<\/p>\n

Finally, the demo app XAML needs to be updated:
\n[xml]
\n<Grid>
\n <Grid.Resources>
\n <DataTemplate x:Key="ItemTemplate">
\n <local:AutomatisableTextBlock Text="{Binding }" \/>
\n <\/DataTemplate>
\n <\/Grid.Resources>
\n <ListBox ItemsSource="{Binding }"
\n ItemTemplate="{StaticResource ItemTemplate}" \/>
\n<\/Grid>[\/xml]<\/p>\n

After the update, the TextBlock is correctly found by any automation client:
\n
\"\"<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

In the previous post, we have seen that setting the AutomationId can greatly help us when we want to perform some UI Tests. Todyay, I struggled with a problem which seems common after some digging…<\/p>\n","protected":false},"author":3,"featured_media":816,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[27,6,4,5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/806"}],"collection":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/comments?post=806"}],"version-history":[{"count":12,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/806\/revisions"}],"predecessor-version":[{"id":820,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/806\/revisions\/820"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media\/816"}],"wp:attachment":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media?parent=806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/categories?post=806"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/tags?post=806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}