{"id":805,"date":"2013-01-02T07:54:50","date_gmt":"2013-01-02T07:54:50","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=805"},"modified":"2024-04-12T14:13:14","modified_gmt":"2024-04-12T08:43:14","slug":"locating-by-dom","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/","title":{"rendered":"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a ref=\"magnificPopup\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"400\" src=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png\" alt=\"Selenium IDE | Locating by DOM &amp; CSS | Locating Hyperlinks by Link Texts\" class=\"wp-image-93473\" srcset=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png 750w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17-300x160.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/a><\/figure><\/div>\n\n\n<h3><strong>Selenium IDE | Locating by DOM<\/strong><\/h3>\n<p>Let&#8217;s learn about Selenium IDE important topic.<\/p>\n<p><strong>Locating by DOM<\/strong> &#8211; The Document Object Model represents an HTML document and can be accessed using JavaScript. This location strategy takes JavaScript that evaluates to an element on the page, which can be simply the element\u2019s location using the hierarchical dotted notation.<\/p>\n<p>Since only dom locators start with \u201cdocument\u201d, it is not necessary to include the dom= label when specifying a DOM locator.<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;form id=&#8221;loginForm&#8221;&gt;<\/p>\n<p>&lt;input name=&#8221;username&#8221; type=&#8221;text&#8221; \/&gt;<\/p>\n<p>&lt;input name=&#8221;password&#8221; type=&#8221;password&#8221; \/&gt;<\/p>\n<p>&lt;input name=&#8221;continue&#8221; type=&#8221;submit&#8221; value=&#8221;Login&#8221; \/&gt;<\/p>\n<p>&lt;input name=&#8221;continue&#8221; type=&#8221;button&#8221; value=&#8221;Clear&#8221; \/&gt;<\/p>\n<p>&lt;\/form&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>\u00a0<\/p>\n<ul>\n<li>dom=document.getElementById(&#8216;loginForm&#8217;) (3)<\/li>\n<li>dom=document.forms[&#8216;loginForm&#8217;] (3)<\/li>\n<li>dom=document.forms[0] (3)<\/li>\n<li>forms[0].username (4)<\/li>\n<li>forms[0].elements[&#8216;username&#8217;] (4)<\/li>\n<li>forms[0].elements[0] (4)<\/li>\n<li>forms[0].elements[3] (7)<\/li>\n<\/ul>\n<p>You can use Selenium IDE itself as well as other sites and extensions to explore the DOM of web application.<\/p>\n<ul>\n<li><strong>Locating by CSS: <\/strong>CSS (Cascading Style Sheets) is a language for describing the rendering of HTML and XML documents CSS uses Selectors for binding style properties to elements in the document These Selectors can be used by Selenium as another locating strategy.<\/li>\n<\/ul>\n<p>&lt;html&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;form id=&#8221;loginForm&#8221;&gt;<\/p>\n<p>&lt;input class=&#8221;required&#8221; name=&#8221;username&#8221; type=&#8221;text&#8221; \/&gt;<\/p>\n<p>&lt;input class=&#8221;required passfield&#8221; name=&#8221;password&#8221; type=&#8221;password&#8221; \/&gt;<\/p>\n<p>&lt;input name=&#8221;continue&#8221; type=&#8221;submit&#8221; value=&#8221;Login&#8221; \/&gt;<\/p>\n<p>&lt;input name=&#8221;continue&#8221; type=&#8221;button&#8221; value=&#8221;Clear&#8221; \/&gt;<\/p>\n<p>&lt;\/form&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<ul>\n<li>css=form#loginForm (3)<\/li>\n<li>css=input[name=&#8221;username&#8221;] (4)<\/li>\n<li>css=input.required[type=&#8221;text&#8221;] (4)<\/li>\n<li>css=input.passfield (5)<\/li>\n<li>css=#loginForm input[type=&#8221;button&#8221;] (7)<\/li>\n<li>css=#loginForm input:nth-child(2) (5)<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<p>Most experienced Selenium IDE users recommend CSS as their locating strategy of choice as it\u2019s considerably faster than XPath and can find the most complicated objects in an intrinsic HTML document.<\/p>\n<h4><strong>Implicit Locators<\/strong><\/h4>\n<p>You can choose to omit the locator type in the following situations:<\/p>\n<ul>\n<li>Locators without an explicitly defined locator strategy will default to using the identifier locator strategy.<\/li>\n<li>Locators starting with \u201c\/\/\u201d will use the XPath locator strategy.<\/li>\n<li>Locators starting with \u201cdocument\u201d will use the DOM locator strategy.<\/li>\n<\/ul>\n<p><strong>Locating Hyperlinks by Link Text: <\/strong>This is a simple method of locating a hyperlink in a web page by using the text of the link. If two links with the same text are present, then the first match will be used.<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;p&gt;Are you sure you want to do this?&lt;\/p&gt;<\/p>\n<p>&lt;a href=&#8221;continue.html&#8221;&gt;Continue&lt;\/a&gt;<\/p>\n<p>&lt;a href=&#8221;cancel.html&#8221;&gt;Cancel&lt;\/a&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<ul>\n<li>link=Continue (4)<\/li>\n<li>link=Cancel (5)<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<div class=\"apply\">\n<div class=\"apply\">\n<p><a href=\"https:\/\/www.vskills.in\/practice\/selenium\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-93268 size-full aligncenter\" src=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Free-Practice-test.png\" alt=\"Selenium professional free practice test\" width=\"960\" height=\"150\" srcset=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Free-Practice-test.png 960w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Free-Practice-test-300x47.png 300w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/p>\n<\/div>\n<\/div>\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/selenium-certification\/\" target=\"_blank\" rel=\"noreferrer noopener\">Go back to Tutorial<\/a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"https:\/\/www.vskills.in\/certification\/testing\/certified-selenium-professional\" target=\"_blank\" rel=\"noreferrer noopener\">Go to Home Page<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Selenium IDE | Locating by DOM Let&#8217;s learn about Selenium IDE important topic. Locating by DOM &#8211; The Document Object Model represents an HTML document and can be accessed using JavaScript. This location strategy takes JavaScript that evaluates to an element on the page, which can be simply the element\u2019s location using the hierarchical dotted&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"categories":[350],"tags":[385,7026,349,7027,6821,7025],"class_list":["post-805","page","type-page","status-publish","hentry","category-selenium","tag-locating-by-dom","tag-selenium-automation-testing","tag-selenium-certification","tag-selenium-documentation","tag-selenium-professional","tag-selenium-webdriver"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts<\/title>\n<meta name=\"description\" content=\"Enrich your profile with advanced learning skills and expert tutorials on selenium IDE skills. Become Certified Selenium Professional Now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts\" \/>\n<meta property=\"og:description\" content=\"Enrich your profile with advanced learning skills and expert tutorials on selenium IDE skills. Become Certified Selenium Professional Now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:43:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/\",\"name\":\"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png\",\"datePublished\":\"2013-01-02T07:54:50+00:00\",\"dateModified\":\"2024-04-12T08:43:14+00:00\",\"description\":\"Enrich your profile with advanced learning skills and expert tutorials on selenium IDE skills. Become Certified Selenium Professional Now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#primaryimage\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png\",\"width\":750,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts","description":"Enrich your profile with advanced learning skills and expert tutorials on selenium IDE skills. Become Certified Selenium Professional Now!","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:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/","og_locale":"en_US","og_type":"article","og_title":"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts","og_description":"Enrich your profile with advanced learning skills and expert tutorials on selenium IDE skills. Become Certified Selenium Professional Now!","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:43:14+00:00","og_image":[{"url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/","name":"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#primaryimage"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png","datePublished":"2013-01-02T07:54:50+00:00","dateModified":"2024-04-12T08:43:14+00:00","description":"Enrich your profile with advanced learning skills and expert tutorials on selenium IDE skills. Become Certified Selenium Professional Now!","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#primaryimage","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2020\/12\/Certified-Selenium-Professional-17.png","width":750,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/locating-by-dom\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Selenium IDE | Locating by DOM| Locating Hyperlinks by Link Texts"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=805"}],"version-history":[{"count":21,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/805\/revisions"}],"predecessor-version":[{"id":93483,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/805\/revisions\/93483"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}