{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/10589","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/10589/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/10589/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/10589/events","html_url":"https://github.com/joomla/joomla-cms/pull/10589","id":156124743,"number":10589,"title":"[tests] Add html5 data- attribute to be used by acceptance tests","user":{"login":"javigomez","id":1375475,"avatar_url":"https://avatars.githubusercontent.com/u/1375475?v=3","gravatar_id":"","url":"https://api.github.com/users/javigomez","html_url":"https://github.com/javigomez","followers_url":"https://api.github.com/users/javigomez/followers","following_url":"https://api.github.com/users/javigomez/following{/other_user}","gists_url":"https://api.github.com/users/javigomez/gists{/gist_id}","starred_url":"https://api.github.com/users/javigomez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javigomez/subscriptions","organizations_url":"https://api.github.com/users/javigomez/orgs","repos_url":"https://api.github.com/users/javigomez/repos","events_url":"https://api.github.com/users/javigomez/events{/privacy}","received_events_url":"https://api.github.com/users/javigomez/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/joomla/joomla-cms/labels/PR-staging","name":"PR-staging","color":"c7def8"}],"state":"closed","locked":false,"assignee":{"login":"roland-d","id":359377,"avatar_url":"https://avatars.githubusercontent.com/u/359377?v=3","gravatar_id":"","url":"https://api.github.com/users/roland-d","html_url":"https://github.com/roland-d","followers_url":"https://api.github.com/users/roland-d/followers","following_url":"https://api.github.com/users/roland-d/following{/other_user}","gists_url":"https://api.github.com/users/roland-d/gists{/gist_id}","starred_url":"https://api.github.com/users/roland-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roland-d/subscriptions","organizations_url":"https://api.github.com/users/roland-d/orgs","repos_url":"https://api.github.com/users/roland-d/repos","events_url":"https://api.github.com/users/roland-d/events{/privacy}","received_events_url":"https://api.github.com/users/roland-d/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-05-21T22:33:58Z","updated_at":"2016-05-26T12:08:04Z","closed_at":"2016-05-26T12:08:04Z","pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/10589","html_url":"https://github.com/joomla/joomla-cms/pull/10589","diff_url":"https://github.com/joomla/joomla-cms/pull/10589.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/10589.patch"},"body":"This pull is created by for the works of the Automated Testing Working Group\r\n\r\n#### Summary of Changes\r\nSometimes we need to write a very complex xpath to locate a element in the page, for example:\r\n\r\n$I->click(['xpath' =>  \"//*[@id=\\\"menuList\\\"]/tbody/tr/td[2]/a[contains(text(), 'weblink')\"])\r\n\r\nInstead of challenging the location abilities of the tester, is much easier to modify the output of the template by adding attributes that ease the location:\r\n\r\n```\r\n$I->fillField(['css' => 'input[data-tests=\"username\"]'], $username);\r\n```\r\n\r\nnote that is important that our tests are readable, and that has to do with using readable locators.\r\n\r\nWe came to the conclusion that using `data-` [html5 attribute](https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes) we will not affect the accessibility nor the functionality.\r\n\r\nThis element locators will allow us to make our tests not fail when the name of a button or a title changes like it happened in the past with: https://github.com/joomla-extensions/weblinks/issues/75.\r\n\r\nI'm opening this pull request being a small example of the changes that we plan to do in the Joomla templates. We would like to get community feedback to ensure we will not affect anyone with them. \r\n\r\nWe have had experiences in the past that this kind of changes can also improve the current output, see for example this issue: https://github.com/joomla/joomla-cms/issues/7207.\r\n\r\n#### Testing Instructions\r\n- You should be able to login in Joomla administrator without notice any change\r\n\r\n# Notes\r\nNote for Automated Testing Working Group: we originally planned to use css classes for this as we specified at https://docs.joomla.org/Testing_Joomla_Extensions_with_Codeception#Write_complex_locator_VS._modifying_the_output_of_the_tested_website, but after a small performance tests done by me, @yvesh and @810 we have concluded that the tests performance is not affected:\r\n\r\n```\r\nAs a class: ✔ administrator login: Successful login (34.3448s) <= test repeated 10 times\r\nAs an attribute: ✔ administrator login: Successful login (32.3201s)  <= test repeated 10 times\r\n```\r\n\r\nAnd using a `data-tests attribute` make our tests more readable than using `css classes`. Therefore we plan to change the best practice from css classes into data- html5 attributes."},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/221853159","html_url":"https://github.com/joomla/joomla-cms/pull/10589#issuecomment-221853159","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/10589","id":221853159,"user":{"login":"javigomez","id":1375475,"avatar_url":"https://avatars.githubusercontent.com/u/1375475?v=3","gravatar_id":"","url":"https://api.github.com/users/javigomez","html_url":"https://github.com/javigomez","followers_url":"https://api.github.com/users/javigomez/followers","following_url":"https://api.github.com/users/javigomez/following{/other_user}","gists_url":"https://api.github.com/users/javigomez/gists{/gist_id}","starred_url":"https://api.github.com/users/javigomez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javigomez/subscriptions","organizations_url":"https://api.github.com/users/javigomez/orgs","repos_url":"https://api.github.com/users/javigomez/repos","events_url":"https://api.github.com/users/javigomez/events{/privacy}","received_events_url":"https://api.github.com/users/javigomez/received_events","type":"User","site_admin":false},"created_at":"2016-05-26T12:08:04Z","updated_at":"2016-05-26T12:08:04Z","body":"Id's are more performant definitely but from our performance checks the difference is not significant. \r\n\r\nAgainst IDs the locator do not contain the type of element that we are interacting with: input, link, textarea... in that sense the data-* alternative improves readability of the tests, and the output, easying to debug an issue. \r\nAnyway we could do ['xpath' => 'input[@id=\"passwd\"]'] but then we would not use the performant Selenium strict id locator but the XPath search.\r\n\r\nHaving the QA team adding IDs to the joomla template is risky, because we could end up adding more than one same id per page. In that case data-* could not cause issue. And, in addition, I'm not sure but I guess it would go against the web semantics.\r\n\r\nAlso for readability, the IDs do not allow spaces, while in a data-test attribute we can describe the element. For example: data-test=`toolbar button Save & Close`.\r\n\r\nLogin is not a good example, because it already has IDs in place, so it was not necessary to add the data-*. For cases like Login we can reuse the existing locators. So we are working on a way to use readable names in test that replaces the locator.\r\n \r\nI'm closing and I'll prepare a more clear example and I will reopen. \r\n"}}
{"actor":{"display_login":"javigomez"}}