{"id":22147,"date":"2020-08-26T16:08:38","date_gmt":"2020-08-26T16:08:38","guid":{"rendered":"http:\/\/mythbusters_part_1_automated_ui_tests_are_unstable"},"modified":"2024-08-22T10:12:38","modified_gmt":"2024-08-22T17:12:38","slug":"mythbusters_part_1_automated_ui_tests_are_unstable","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable","title":{"rendered":"MythBusters, Part 1: &#8216;Automated UI Tests Are Unstable&#8217;"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>Even though most people agree that testing software UI is important, many believe that automated tests are slow and unstable. Consequently, many technology companies prefer manual testing. I\u2019ll convince you otherwise in this post: even though automating UI tests and ensuring that they are fast and reliable is tough to accomplish, it\u2019s definitely doable.<\/p>\n<h2>Construction of Reliable Selectors<\/h2>\n<p>I once asked a friend why his company didn\u2019t automate UI testing. He replied, \u201cBecause the tests break easily. For example, if an engineer changes something in the <a href=\"https:\/\/www.w3schools.com\/whatis\/whatis_htmldom.asp\">DOM<\/a>, it causes errors in the tests.\u201d<\/p>\n<p>However, that issue is solvable. For example, a popular question among automation engineers is which selectors are the best. The common answer is <code>id<\/code> or <code>class<\/code>, rather than <code>XPath<\/code>, which could fail. Let me bust this myth and explain how to render automation frameworks reliable.<\/p>\n<p>Choosing <code>id<\/code> for selectors has a caveat: the value must be unique for the document, which means that it doesn\u2019t work in the case of multiple identical UI components, such as the <code>&lt;input&gt;<\/code> element. As a resolution, our automation group at Cloudinary opted to identify locators with an attribute called <code>data-test<\/code> by leveraging standard <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/HTML\/Howto\/Use_data_attributes\">data-*<\/a> attributes. Instead of just picking the least risky attribute that exists, we added <code>data-test<\/code> to the application code. Not only do searches for the web element then become stable, developers are also free to change IDs and class names.<\/p>\n<p>Additionally, as a rule, front-end developers add logic or styling with IDs or classes. Leveraging a unique attribute creates a convention that distinctly separates development and QA, leading to transparency and clarity.<\/p>\n<p>Here\u2019s another example:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/image\/upload\/w_300,c_fill,f_auto,q_auto,dpr_2.0\/Web_Assets\/blog\/metadata.png\" alt=\"metadata\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"300\" height=\"172\"\/>\n<img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/image\/upload\/w_700,c_fill,f_auto,q_auto,dpr_2.0\/Web_Assets\/blog\/WithoutDataTest.png\" alt=\"class name\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"700\" height=\"66.5\"\/><\/p>\n<p>Class names don\u2019t work here because the styling libraries, which handle scoping, automatically generate the classes. Hence, classes are not a reliable source, and the component is not unique in the DOM.<\/p>\n<p>However, adding the automation attribute <code>data-test<\/code> to the component leaves the UI intact, enabling QA engineers to build a stable and consistent selector.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/image\/upload\/w_700,c_fill,f_auto,q_auto,dpr_2.0\/Web_Assets\/blog\/WithDataTest.png\" alt=\"Class name\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"700\" height=\"72.5\"\/><\/p>\n<p>Some of you wondered about the performance of having data attributes act as selectors. Assuringly, the lookup time between class and data attributes is usually the same.<\/p>\n<h2>Summary<\/h2>\n<p>To recap, if planned and executed correctly, E2E UI tests can be sound, efficient, and flexible. Front-end developers will be at liberty to tweak the DOM with no need for the QA automation team to make corresponding adjustments, saving time for everyone. Bottom line: this process makes it easier to look for the right selector.<\/p>\n<p>Part 2 of this series will bust another myth: \u201cAutomating E2E is time-consuming.\u201d Stay tuned.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":41,"featured_media":22148,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-22147","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>MythBusters, Part 1: \u201cAutomated UI Tests Are Unstable\u201d<\/title>\n<meta name=\"description\" content=\"Cloudinary QA automation builds reliable selectors with attributes in automated UI tests, resulting in efficiency and transparency between QA and development.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MythBusters, Part 1: &#039;Automated UI Tests Are Unstable&#039;\" \/>\n<meta property=\"og:description\" content=\"Cloudinary QA automation builds reliable selectors with attributes in automated UI tests, resulting in efficiency and transparency between QA and development.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-26T16:08:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-22T17:12:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1-png?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"1540\" \/>\n\t<meta property=\"og:image:height\" content=\"847\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"MythBusters, Part 1: &#8216;Automated UI Tests Are Unstable&#8217;\",\"datePublished\":\"2020-08-26T16:08:38+00:00\",\"dateModified\":\"2024-08-22T17:12:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable\"},\"wordCount\":7,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA\",\"inLanguage\":\"en-US\",\"copyrightYear\":\"2020\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable\",\"url\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable\",\"name\":\"MythBusters, Part 1: \u201cAutomated UI Tests Are Unstable\u201d\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA\",\"datePublished\":\"2020-08-26T16:08:38+00:00\",\"dateModified\":\"2024-08-22T17:12:38+00:00\",\"description\":\"Cloudinary QA automation builds reliable selectors with attributes in automated UI tests, resulting in efficiency and transparency between QA and development.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA\",\"width\":1540,\"height\":847},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MythBusters, Part 1: &#8216;Automated UI Tests Are Unstable&#8217;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"MythBusters, Part 1: \u201cAutomated UI Tests Are Unstable\u201d","description":"Cloudinary QA automation builds reliable selectors with attributes in automated UI tests, resulting in efficiency and transparency between QA and development.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable","og_locale":"en_US","og_type":"article","og_title":"MythBusters, Part 1: 'Automated UI Tests Are Unstable'","og_description":"Cloudinary QA automation builds reliable selectors with attributes in automated UI tests, resulting in efficiency and transparency between QA and development.","og_url":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable","og_site_name":"Cloudinary Blog","article_published_time":"2020-08-26T16:08:38+00:00","article_modified_time":"2024-08-22T17:12:38+00:00","og_image":[{"width":1540,"height":847,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1-png?_i=AA","type":"image\/png"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable"},"author":{"name":"","@id":""},"headline":"MythBusters, Part 1: &#8216;Automated UI Tests Are Unstable&#8217;","datePublished":"2020-08-26T16:08:38+00:00","dateModified":"2024-08-22T17:12:38+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable"},"wordCount":7,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA","inLanguage":"en-US","copyrightYear":"2020","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable","url":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable","name":"MythBusters, Part 1: \u201cAutomated UI Tests Are Unstable\u201d","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA","datePublished":"2020-08-26T16:08:38+00:00","dateModified":"2024-08-22T17:12:38+00:00","description":"Cloudinary QA automation builds reliable selectors with attributes in automated UI tests, resulting in efficiency and transparency between QA and development.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA","width":1540,"height":847},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/mythbusters_part_1_automated_ui_tests_are_unstable#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"MythBusters, Part 1: &#8216;Automated UI Tests Are Unstable&#8217;"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":""}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649719258\/Web_Assets\/blog\/Mythbusters-UI-Automation-is-Breakable_2214888fb1\/Mythbusters-UI-Automation-is-Breakable_2214888fb1.png?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/22147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=22147"}],"version-history":[{"count":1,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/22147\/revisions"}],"predecessor-version":[{"id":35433,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/22147\/revisions\/35433"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/22148"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=22147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=22147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=22147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}