{"id":3749,"date":"2016-06-10T06:50:49","date_gmt":"2016-06-10T10:50:49","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=3749"},"modified":"2018-04-03T10:36:09","modified_gmt":"2018-04-03T14:36:09","slug":"how-to-write-css-selectors","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/how-to-write-css-selectors\/","title":{"rendered":"How to write CSS selectors"},"content":{"rendered":"<h3>Why this post?<\/h3>\n<p>Testers need to know multiple ways of locating an element in a webpage as different strategies have to be used based on the context since each has its own advantage. The Cascading Style Sheet(CSS) is defined to structure and style the HTML in the webpage. These CSS patterns can be used to uniquely identify elements in the webpage. This post will help you get started with CSS selectors. I have modeled this post to address the difficulties I faced learning CSS selectors online.<\/p>\n<hr\/>\n<h3>Setup<\/h3>\n<p>A couple of difficulties I faced while learning CSS is that most posts are pretty mundane and very abstract. I have made an effort to not do the same. Every example I have used in this post is derived from the  <a href=\"https:\/\/qxf2.com\/selenium-tutorial-main\">Qxf2 tutorial page<\/a> that will never change. That way you can practice writing CSS selectors to your heart&#8217;s content.<\/p>\n<p>Install the <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/css-and-xpath-checker\/aoinfihhckpkkcpholfhmkeplbhddipe?hl=en\">CSS and XPath checker<\/a> plugin for Chrome, open the tutorial page on a new tab and follow along.<\/p>\n<hr\/>\n<h3>Overview<\/h3>\n<p>This post has been structured in a way that it:<br \/>\n1. gets you started with the basic patterns<br \/>\n2. introduces you to positional pseudo-classes<br \/>\n3. tabulates a few useful patterns.<\/p>\n<h5>1)Basic patterns<\/h5>\n<p>Basic patterns include identifying elements by their tag, by their id, by their name attribute and their class. For example, let us try deriving CSS selectors for the Phone No text field in the tutorial page.<\/p>\n<p>To view the html properties of the Phone No field, right click on it and select inspect.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_html.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_html.png\" alt=\"Phone_html\" width=\"470\" height=\"25\" class=\"aligncenter size-full wp-image-4006\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_html.png 470w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_html-300x16.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/a><br \/>\nTo select the Phone No textfield,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id_21.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id_21.png\" alt=\"Phone_Css_id_2\" width=\"323\" height=\"71\" class=\"aligncenter size-full wp-image-4023\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id_21.png 323w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id_21-300x66.png 300w\" sizes=\"auto, (max-width: 323px) 100vw, 323px\" \/><\/a><br \/>\nor<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id.png\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id.png\" alt=\"Phone_Css_id\" width=\"327\" height=\"71\" class=\"aligncenter size-full wp-image-4008\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id.png 327w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_Css_id-300x65.png 300w\" sizes=\"auto, (max-width: 327px) 100vw, 327px\" \/><\/a><br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_no1.png\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_no1.png\" alt=\"Phone_no\" width=\"584\" height=\"436\" class=\"aligncenter size-full wp-image-4069\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_no1.png 584w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Phone_no1-300x224.png 300w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><br \/>\nAlthough #phone can be used to locate the text field,there can be other CSS locators too for the Phone No text field.You can practice the remaining basic patterns (HTML tag, id, class) by referring to the table below. <\/p>\n<table>\n<thead>\n<tr>\n<td><b>Selector<\/b><\/td>\n<td><b>Example<\/b><\/td>\n<td><b>Example Description<\/b><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>element<\/td>\n<td ><em>input<\/em><\/td>\n<td>This pattern selects all input elements in the web page.<\/td>\n<\/tr>\n<tr>\n<td>.class<\/td>\n<td><em>div.checkbox (or) .checkbox<\/em><\/td>\n<td>This pattern selects the element with the class .checkbox<\/td>\n<\/tr>\n<tr>\n<td>[attribute=&#8217;value&#8217;]<\/td>\n<td><em>input[type=&#8217;phone&#8217;] (or) [type=&#8217;phone&#8217;] <\/em><\/td>\n<td>This pattern selects the input element whose type attribute value is phone.<\/td>\n<\/tr>\n<\/table>\n<p>Consider the following HTML property for the Example Table,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Example_Table.png\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Example_Table.png\" alt=\"Example_Table\" width=\"503\" height=\"31\" class=\"aligncenter size-full wp-image-4019\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Example_Table.png 503w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Example_Table-300x18.png 300w\" sizes=\"auto, (max-width: 503px) 100vw, 503px\" \/><\/a><br \/>\nThe CSS selector for the above table can be <code>[name='Example Table']<\/code> or to specify that the value starts with a particular word <code>[name^='Example']<\/code> or <code>[name$='Table']<\/code> if the value ends with word Table. <code>[name*='Example] or [name*='Table'] <\/code> can be used to specify that the value of the attribute contains the particular word.<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/name_cont_css.png\" data-rel=\"lightbox-image-5\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/name_cont_css.png\" alt=\"name_cont_css\" width=\"322\" height=\"67\" class=\"aligncenter size-full wp-image-4055\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/name_cont_css.png 322w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/name_cont_css-300x62.png 300w\" sizes=\"auto, (max-width: 322px) 100vw, 322px\" \/><\/a><\/p>\n<hr\/>\n<h5>2)Pseudo-class<\/h5>\n<p>Sometimes you are lucky and every element in your application has a name or an id or a unique class. However, when you start dealing with tables and dynamic data, it is good to know about Pseudo-classes. Pseudo-classes are used to locate an element based on their state\/position. Pseudo-classes are preceded by &#8216;:&#8217;. Let us try writing selectors for the buttons in the example form with pseudo-classes.<br \/>\nLet us try deriving a CSS selector for the Click me! button using a pseudo-class. The HTML snippet for the Click me! button is,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/05\/click_me_button.png\" data-rel=\"lightbox-image-6\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3832\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/05\/click_me_button.png\" alt=\"click_me_button\" width=\"539\" height=\"346\" \/><\/a><br \/>\nThe CSS selector using pseudo-class is,<br \/>\n <a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Click_me_CSS.png\" data-rel=\"lightbox-image-7\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Click_me_CSS.png\" alt=\"Click_me_CSS\" width=\"322\" height=\"66\" class=\"aligncenter size-full wp-image-4027\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Click_me_CSS.png 322w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Click_me_CSS-300x61.png 300w\" sizes=\"auto, (max-width: 322px) 100vw, 322px\" \/><\/a><br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/click_me_example_form.png\" data-rel=\"lightbox-image-8\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/click_me_example_form.png\" alt=\"click_me_example_form\" width=\"569\" height=\"376\" class=\"aligncenter size-full wp-image-4031\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/click_me_example_form.png 569w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/click_me_example_form-300x198.png 300w\" sizes=\"auto, (max-width: 569px) 100vw, 569px\" \/><\/a><br \/>\nNow the HTML snippet for Gender button is,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/05\/gender_button.png\" data-rel=\"lightbox-image-9\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3831\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/05\/gender_button.png\" alt=\"gender_button\" width=\"688\" height=\"61\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/05\/gender_button.png 688w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/05\/gender_button-300x27.png 300w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/a><br \/>\nThe CSS selector for the Gender button can be,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/first_child_css1.png\" data-rel=\"lightbox-image-10\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/first_child_css1.png\" alt=\"first_child_css\" width=\"325\" height=\"69\" class=\"aligncenter size-full wp-image-4046\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/first_child_css1.png 325w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/first_child_css1-300x64.png 300w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><\/a><br \/>\nDo you notice 2 matches instead of one? Wondering why?? The Click me! button despite being the only child is also taken into consideration for the <code>first-child<\/code> pseudo class. Hence the pseudo-class has to be used in combination with any other basic patterns. Therefore the CSS selector for the gender button is,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_CSS.png\" data-rel=\"lightbox-image-11\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_CSS.png\" alt=\"Gender_CSS\" width=\"322\" height=\"68\" class=\"aligncenter size-full wp-image-4029\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_CSS.png 322w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_CSS-300x63.png 300w\" sizes=\"auto, (max-width: 322px) 100vw, 322px\" \/><\/a><br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_example_form.png\" data-rel=\"lightbox-image-12\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_example_form.png\" alt=\"Gender_example_form\" width=\"571\" height=\"382\" class=\"aligncenter size-full wp-image-4030\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_example_form.png 571w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/Gender_example_form-300x201.png 300w\" sizes=\"auto, (max-width: 571px) 100vw, 571px\" \/><\/a><br \/>\nIt is not possible to discuss all the Pseudo-classes(for more pseudo classes click <a href=\"http:\/\/www.w3schools.com\/css\/css_pseudo_classes.asp\">here<\/a>.) but anyone who wants to learn CSS should start by knowing the difference between the most commonly used position based pseudo-classes &#8211; <code>nth-child<\/code> and <code>nth-of-type<\/code> classes. Let us try and learn the difference with the following example,<br \/>\nConsider the HTML properties of the Example Form in the tutorial page:<\/p>\n<pre lang='js'>\r\n\t    <div class=\"form-group\">\r\n\t      <label for=\"name\">Name:<\/label>\r\n\t      <input type=\"name\" class=\"form-control\" name=\"name\" id=\"name\" >\r\n\t    <\/div>\r\n\t    <div class=\"form-group\">\r\n\t      <label for=\"email\">Email:<\/label>\r\n\t      <input type=\"email\" class=\"form-control\" name=\"email\">\r\n\t    <\/div>\r\n\t    <div class=\"form-group\">\r\n\t      <label for=\"pwd\">Phone No:<\/label>\r\n\t      <input type=\"phone\" class=\"form-control\" name=\"phone\" id=\"phone\">\r\n\t    <\/div>\r\n<\/pre>\n<p>The CSS selector to select the email text field would be <code>div.form-group:nth-child(2)<\/code>. The nth-child pseudo-class here would select any element that is a <code>div<\/code> and is the second child. The CSS selector for the above element can also be<\/p>\n<pre lang='js'>div.form-group:nth-of-type(2)<\/pre>\n<p>The <code>nth-of-type<\/code> pseudo-class selects any element that is second of the type<br \/>\nImagine if developer decides to have a gender button next to the name field, the HTML properties after the new change would look like this,<\/p>\n<pre lang='js'>\r\n\t    <div class=\"form-group\">\r\n\t      <label for=\"name\">Name:<\/label>\r\n\t      <input type=\"name\" class=\"form-control\" name=\"name\" id=\"name\" >\r\n\t    <\/div>\r\n\t    <span class=\"form-group\">\r\n\t      <button class=\"btn btn-primary dropdown-toggle status\" type=\"button\" data-toggle=\"dropdown\">Gender\r\n\t      <\/button>\r\n            <\/span>\r\n\t    <div class=\"form-group\">\r\n\t      <label for=\"email\">Email:<\/label>\r\n\t      <input type=\"email\" class=\"form-control\" name=\"email\">\r\n\t    <\/div>\r\n\t    <div class=\"form-group\">\r\n\t      <label for=\"pwd\">Phone No:<\/label>\r\n\t      <input type=\"phone\" class=\"form-control\" name=\"phone\" id=\"phone\">\r\n\t    <\/div>\r\n<\/pre>\n<p>Now,<\/p>\n<pre lang='js'>div.form-group:nth-child(2)<\/pre>\n<p>Would not identify any element as the <code>div<\/code> element is no longer the second child. Whereas,<\/p>\n<pre lang='js'>div.form-group:nth-of-type(2)<\/pre>\n<p>Would select the email text field as the second <code>div<\/code> element corresponds to the email text field<\/p>\n<hr\/>\n<h5>3)Other important patterns:<\/h5>\n<p>Sometimes the you need to identify elements relative to another well identified element. This section will show you how. Generally these patterns are used in combination with pseudo-classes(except <code>:not<\/code> which is already a pseudo-class).<br \/>\nConsider the following HTML snippet,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/axes_example2.png\" data-rel=\"lightbox-image-13\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/axes_example2.png\" alt=\"axes_example\" width=\"151\" height=\"121\" class=\"aligncenter size-full wp-image-4062\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/axes_example2.png 151w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/axes_example2-150x121.png 150w\" sizes=\"auto, (max-width: 151px) 100vw, 151px\" \/><\/a><br \/>\nTo select the child of any element,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/child2.png\" data-rel=\"lightbox-image-14\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/child2.png\" alt=\"child\" width=\"325\" height=\"64\" class=\"aligncenter size-full wp-image-4073\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/child2.png 325w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/child2-300x59.png 300w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><\/a><br \/>\nAnd to select the grandchild of any element,<br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/grandchild2.png\" data-rel=\"lightbox-image-15\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/grandchild2.png\" alt=\"grandchild\" width=\"324\" height=\"64\" class=\"aligncenter size-full wp-image-4074\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/grandchild2.png 324w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2016\/06\/grandchild2-300x59.png 300w\" sizes=\"auto, (max-width: 324px) 100vw, 324px\" \/><\/a><br \/>\nThe <code>element>child<\/code> pattern is used to select the child of that element. In order to select the child and grandchild of any element  <code>element grandchild<\/code> pattern can be used. The reason why you see 4 matches is because there are 4 <code>th<\/code> elements in the Example Table.<br \/>\nTry out the other useful patterns in the following table,<\/p>\n<table>\n<thead>\n<tr>\n<td><b>Selector<\/b><\/td>\n<td><b>Example<\/b><\/td>\n<td><b>Example Description<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>element+element<\/td>\n<td><em>label+input<\/em><\/td>\n<td>This pattern is used to select the input element that is immediately next to the label  element<\/td>\n<\/tr>\n<tr>\n<td>element~element<\/td>\n<td><em>label~input<\/em><\/td>\n<td>This pattern is used to select the input that is after the label element. Unlike the previous example the input element doesn&#8217;t necessarily have to be next to label<\/td>\n<\/tr>\n<tr>\n<td>element,element<\/td>\n<td><em>input#name,input#random<\/em><\/td>\n<td>This pattern selects both elements or any element that is present<\/td>\n<\/tr>\n<tr>\n<td>not<\/td>\n<td><em>:not(input)<\/em<<\/td>\n<td>This pattern selects every element that is not an input element<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr\/>\n<h3>References<\/h3>\n<p>1. Flukeout-CSS diner game :<a href=\"http:\/\/flukeout.github.io\/\">flukeout CSS Diner<\/a><br \/>\n2. Chris Coyier&#8217;s piece on pseudo-class: <a href=\"https:\/\/css-tricks.com\/pseudo-class-selectors\/\">https:\/\/css-tricks.com\/pseudo-class-selectors\/<\/a><br \/>\n3. How to use CSS selectors for identifying webelements post on softwaretestinghelp.com: <a href=\"http:\/\/www.softwaretestinghelp.com\/css-selector-selenium-locator-selenium-tutorial-6\/\">http:\/\/www.softwaretestinghelp.com\/css-selector-selenium-locator-selenium-tutorial-6\/<\/a><br \/>\n4. w3schools.com: <a href=\"http:\/\/www.w3schools.com\/cssref\/css_selectors.asp\">http:\/\/www.w3schools.com\/cssref\/css_selectors.asp<\/a><\/p>\n<hr\/>\n<h3>A fun practice exercise!<\/h3>\n<p>Someone gamified learning to write CSS selectors and we love it!! Checkout <a href=\"http:\/\/flukeout.github.io\/\">flukeout CSS Diner<\/a>. I know we mentioned this a couple of times, but it is worth repeating again!<\/p>\n<p><strong>If you liked this article, learn more <a href=\"https:\/\/qxf2.com\/blog\/about-qxf2\/\">about Qxf2&#8217;s<\/a> testing services for startups.<\/strong><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>Why this post? Testers need to know multiple ways of locating an element in a webpage as different strategies have to be used based on the context since each has its own advantage. The Cascading Style Sheet(CSS) is defined to structure and style the HTML in the webpage. These CSS patterns can be used to uniquely identify elements in the [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,30],"tags":[],"class_list":["post-3749","post","type-post","status-publish","format-standard","hentry","category-css","category-selenium"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/3749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=3749"}],"version-history":[{"count":278,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/3749\/revisions"}],"predecessor-version":[{"id":12373,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/3749\/revisions\/12373"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=3749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=3749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=3749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}