{"id":93311,"date":"2019-06-21T11:25:42","date_gmt":"2019-06-21T08:25:42","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=93311"},"modified":"2019-06-21T11:23:29","modified_gmt":"2019-06-21T08:23:29","slug":"selenium-java-tutorial-class-name-locator-selenium","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html","title":{"rendered":"Selenium Java Tutorial \u2013 Class Name Locator In Selenium"},"content":{"rendered":"<p>CSS Locator in Selenium is one of the most important aspects of writing a script. If you cannot locate an element by using any CSS locator in Selenium, then being proficient at <a href=\"https:\/\/www.lambdatest.com\/selenium-automation\" target=\"_blank\" rel=\"noopener noreferrer\">Selenium automation<\/a> will be a tough task. Selenium provides multiple ways of locating an element.<\/p>\n<p>You can check out other articles around different CSS locator in Selenium that helps in locating elements through various ways:<\/p>\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.lambdatest.com\/blog\/using-link-text-and-partial-link-text-in-selenium\/\" target=\"_blank\" rel=\"noopener noreferrer\"> Link Text &amp; Partial Link Text In Selenium<\/a><\/li>\n<li><a href=\"https:\/\/www.lambdatest.com\/blog\/making-the-move-with-id-locator-in-selenium-webdriver\/\" target=\"_blank\" rel=\"noopener noreferrer\">ID locator in Selenium<\/a><\/li>\n<li><a href=\"https:\/\/www.lambdatest.com\/blog\/how-to-use-name-locator-in-selenium-automation-scripts\/\" target=\"_blank\" rel=\"noopener noreferrer\">Name locator in Selenium<\/a><\/li>\n<li><a href=\"https:\/\/www.lambdatest.com\/blog\/locating-elements-by-tagname-in-selenium\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tagname locator in Selenium<\/a><\/li>\n<li><a href=\"https:\/\/www.lambdatest.com\/blog\/how-pro-testers-use-css-selectors-in-selenium-automation-scripts\/\" target=\"_blank\" rel=\"noopener noreferrer\">CSS Selector in Selenium<\/a><\/li>\n<li><a href=\"https:\/\/www.lambdatest.com\/blog\/complete-guide-for-using-xpath-in-selenium-with-examples\/\" target=\"_blank\" rel=\"noopener noreferrer\">XPath in Selenium<\/a><\/li>\n<\/ul>\n<p>If you are an advanced or medium Selenium Java practitioner, then you can chuck on dedicated articles mentioned above. I have written a complete guide to help you illustrate the practical demonstration of CSS locator in Selenium.<\/p>\n<p><a href=\"https:\/\/www.lambdatest.com\/blog\/locators-in-selenium-webdriver-with-examples\/\" target=\"_blank\" rel=\"noopener noreferrer\">Check Out My Complete Guide For Every CSS Locator In Selenium WebDriver With Examples<\/a><\/p>\n<p>In this Selenium Java tutorial, I will be referencing on <b>Class name locator in Selenium<\/b> to demonstrate how to locate an element on a webpage via class name.<\/p>\n<h2 class=\"wp-block-heading\">Getting Started With Class Name Locator In Selenium With Example<\/h2>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"768\" height=\"330\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/pasted-image-0-18-1.png\" alt=\"Class Name Locator\" class=\"wp-image-93388\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/pasted-image-0-18-1.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/pasted-image-0-18-1-300x129.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>In-order to use Class name locator in Selenium we need to use the below syntax:<br \/><code>findElement(By.className(\"_up0kwni \"))<\/code><\/p>\n<p>Now, let\u2019s look into the code for finding elements by Class name in locators:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">import java.util.concurrent.TimeUnit;\n\nimport org.openqa.selenium.By;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.chrome.ChromeDriver;\n\npublic class ClassNameLocator {\n\n    public static void main(String[] args) {\n        \/\/ TODO Auto-generated method stub\n        \n        System.setProperty(\"webdriver.chrome.driver\", \".\\\\ChromeDriver\\\\chromedriver.exe\");\n        WebDriver driver=new ChromeDriver();\n        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);\n        \n        driver.manage().window().maximize();\n        \n        \/\/Opening the air bnb home page\n        driver.get(\"https:\/\/www.airbnb.co.in\/\");\n        \n        \/\/Locating location field for the search  form via class name \n        driver.findElement(By.className(\"_up0kwni\")).sendKeys(\"Goa\", Keys.ENTER);\n\n        \/\/Locating check-in field for the search  form via class name \n        driver.findElement(By.className(\"_14fdu48d\")).click();\n        \n        \/\/Locating the date 12th June for check-in field\n        driver.findElement(By.className(\"_1wh4xpp1\")).click();\n                \n        \/\/closing the driver\n        driver.quit();\n        \n        \n\n    }\n\n\n}<\/pre>\n<p>Pretty simple, isn\u2019t it? In the upcoming session of this Java Selenium tutorial we will learn how to handle a common exception for class name locator in Selenium.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/accounts.lambdatest.com\/register\/\"><img decoding=\"async\" width=\"431\" height=\"330\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/cta-img-1.png\" alt=\"Class Name Locator\" class=\"wp-image-93389\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/cta-img-1.png 431w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/cta-img-1-300x230.png 300w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/><\/a><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">One Of The Most Common Exceptions For Class Name Locator In Selenium<\/h2>\n<p>Another interesting fact and a popular error you may come across while using Class name locator in Selenium would be something like:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"768\" height=\"33\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image2-1.png\" alt=\"Class Name Locator\" class=\"wp-image-93390\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image2-1.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image2-1-300x13.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>I am sure, you may have come across this error. Lets try to incorporate this scenario in the below code snippet for the Facebook sign up page. Below is the DOM structure for facebook \u2018first name\u2019 field with class name attribute highlighted below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"768\" height=\"48\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image3.png\" alt=\"Class Name Locator\" class=\"wp-image-93391\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image3.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image3-300x19.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>Referenced code snippet, trying to access the first name field using the class name locator in Selenium:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">import java.util.concurrent.TimeUnit;\n\nimport org.openqa.selenium.By;\nimport org.openqa.selenium.Keys;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.chrome.ChromeDriver;\n\npublic class ClassNameLocator {\n\n    public static void main(String[] args) throws InterruptedException {\n        \/\/ TODO Auto-generated method stub\n        \n        System.setProperty(\"webdriver.chrome.driver\", \".\\\\ChromeDriver\\\\chromedriver.exe\");\n        WebDriver driver=new ChromeDriver();\n        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);\n        \n        driver.manage().window().maximize();\n        \n        \/\/Opening the air bnb home page\n        driver.get(\"https:\/\/www.facebook.com\/\");\n        \n        \/\/Locating by firstname via class name \n        driver.findElement(By.className(\"inputtext _58mg _5dba _2ph-\")).sendKeys(\"Sadhvi\");\n        \n                \n        \/\/closing the driver\n        driver.quit();\n        \n        \n\n    }\n\n}<\/pre>\n<p>Referenced Console error below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"768\" height=\"377\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/Locating-Element-By-class-name_03-1.png\" alt=\"Class Name Locator\" class=\"wp-image-93392\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/Locating-Element-By-class-name_03-1.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/Locating-Element-By-class-name_03-1-300x147.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>How to handle this error? Well, Selenium considers this as a compound class, which means more than one classes marked through spaces. So, any class name with spaces in it will be considered two or three or more classes.<\/p>\n<p>In this case, this class name marked as \u2018inputtext _58mg _5dba _2ph-\u2018 contains three spaces thereby making it three different classes. Hence, <b>Selenium mentions the error stating it cannot find multiple classes together<\/b>. In this case, you can opt to locate element by <b>CSS selector in Selenium<\/b> or by <b>XPath in Selenium<\/b> using the <b>class name attribute<\/b>. The referenced code snippet below:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">import java.util.concurrent.TimeUnit;\n\nimport org.openqa.selenium.By;\nimport org.openqa.selenium.Keys;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.chrome.ChromeDriver;\n\npublic class ClassNameLocator {\n\n    public static void main(String[] args) throws InterruptedException {\n        \/\/ TODO Auto-generated method stub\n        \n        System.setProperty(\"webdriver.chrome.driver\", \".\\\\ChromeDriver\\\\chromedriver.exe\");\n        WebDriver driver=new ChromeDriver();\n        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);\n        \n        driver.manage().window().maximize();\n        \n        \/\/Opening the facebook home page\n        driver.get(\"https:\/\/www.facebook.com\/\");\n        \n        \/\/Locating by firstname via class name \n        driver.findElement(By.xpath(\"\/\/input[@class='inputtext _58mg _5dba _2ph-']\")).sendKeys(\"Sadhvi\");\n        \n                \n        \/\/closing the driver\n        driver.quit();\n        \n        \n\n    }\n\n}<\/pre>\n<h2 class=\"wp-block-heading\">How To Locate An Element When We Have Multiple Elements Sharing The Same Class Name?<\/h2>\n<p>Now you know when to use the class name and when you cannot use class names. But did you ever imagine the scenario when you have multiple elements sharing the same class name? How do you tackle that situation? This is again something, you can simply achieve by using the <b>findElements keyword<\/b>. All you need to do is, locate all elements with that class name using the findElements keyword and iterate through the required element class name via index. Having said so, I would rather suggest looking into an alternative method of locating that element rather than this. As its tendency of breaking will be pretty high and may lead to errors.<\/p>\n<h3 class=\"wp-block-heading\">Example For Class Name Locator In Selenium For Multiple Elements With A Similar Class Name<\/h3>\n<p>Let\u2019s consider the below example, highlighting the scenario above. In this case, we are considering the LinkedIn sign-up page, where all fields share the same class name. In this case, we need to note two important things:<\/p>\n<ul class=\"wp-block-list\">\n<li>If no, the index is defined, then by default selenium selects the first element it encounters with that class name. In the code snippet below, it locates the first element which is the first name:<\/li>\n<\/ul>\n<pre class=\"wp-block-preformatted brush:bash\">import java.util.concurrent.TimeUnit;\n\nimport org.openqa.selenium.By;\nimport org.openqa.selenium.Keys;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.chrome.ChromeDriver;\n\npublic class ClassNameLocator {\n\n    public static void main(String[] args) throws InterruptedException {\n        \/\/ TODO Auto-generated method stub\n        \n        System.setProperty(\"webdriver.chrome.driver\", \".\\\\ChromeDriver\\\\chromedriver.exe\");\n        WebDriver driver=new ChromeDriver();\n        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);\n        \n        driver.manage().window().maximize();\n        \n        \/\/Opening the linkedin sign up home page\n        driver.get(\"https:\/\/www.linkedin.com\/start\/join\");\n        \n        \/\/Locating by firstname via class name \n        driver.findElement(By.className(\"cell-body-textinput\")).sendKeys(\"Sadhvi\");\n        \n                \n        \/\/closing the driver\n        driver.quit();\n        \n        \n\n    }\n\n}<\/pre>\n<p>Note: Take a look at the class name, which in this case is cell-body-textinput, since it is not marked with spaces hence it is considered as a single class.<\/p>\n<ul class=\"wp-block-list\">\n<li>Locating the different elements with the same class name using index. The referenced snippet below:<\/li>\n<\/ul>\n<pre class=\"wp-block-preformatted brush:bash\">import java.util.List;\nimport java.util.concurrent.TimeUnit;\n\nimport org.openqa.selenium.By;\nimport org.openqa.selenium.Keys;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.WebElement;\nimport org.openqa.selenium.chrome.ChromeDriver;\n\npublic class ClassNameLocator {\n\n    public static void main(String[] args) throws InterruptedException {\n        \/\/ TODO Auto-generated method stub\n        \n        System.setProperty(\"webdriver.chrome.driver\", \".\\\\ChromeDriver\\\\chromedriver.exe\");\n        WebDriver driver=new ChromeDriver();\n        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);\n        \n        driver.manage().window().maximize();\n        \n        \/\/Opening the air bnb home page\n        driver.get(\"https:\/\/www.linkedin.com\/start\/join\");\n        \n        \/\/Locating by firstname via class name \n        List&lt;webelement&gt; signUpForm=driver.findElements(By.className(\"cell-body-textinput\"));\n        \n        \/\/finding the number of elments with the same class name\n        int size=signUpForm.size();\n        \n        System.out.print(size);\n        \n        \/\/locating the first name locator\n        signUpForm.get(0).sendKeys(\"Sadhvi\");\n        \n        \/\/locating the last name locator\n        signUpForm.get(1).sendKeys(\"Singh\");\n\n\n        \/\/locating the email  locator\n        signUpForm.get(2).sendKeys(\"sadhvisingh24@gmail.com\");\n        \n        \/\/locating the password  locator\n        signUpForm.get(3).sendKeys(\"password\");\n                \n        \n        \/\/closing the driver\n        \/\/driver.quit();\n        \n        \n\n    }\n\n}\n\n&lt;\/webelement&gt;<\/pre>\n<p><b>Console output:<\/b><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"768\" height=\"432\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image4-1.png\" alt=\"Class Name Locator\" class=\"wp-image-93393\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image4-1.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/image4-1-300x169.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>Bingo, you are good to go now. This was all about class name locator in Selenium.<\/p>\n<h2 class=\"wp-block-heading\">What Did We Learn About Class Name Locator In Selenium?<\/h2>\n<p>Well, that was all for today\u2019s Selenium Java tutorial for CSS locator in Selenium. I am sure by far you have developed a deep understanding on how to use the Class name locator in Selenium effectively. We came across the most common error across the implementation of Class name locator in Selenium. We also learned how to overcome complicated scenarios where multiple elements are sharing a similar class name. Adios, happy testing! <\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/accounts.lambdatest.com\/register\/\"><img decoding=\"async\" width=\"768\" height=\"149\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/Adword-Cyber2-1.jpg\" alt=\"Class Name Locator\" class=\"wp-image-93394\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/Adword-Cyber2-1.jpg 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/06\/Adword-Cyber2-1-300x58.jpg 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n<\/div>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Sadhvi Singh, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"https:\/\/www.lambdatest.com\/blog\/selenium-java-tutorial-class-name-locator-in-selenium\/\" target=\"_blank\" rel=\"noopener noreferrer\">Selenium Java Tutorial \u2013 Class Name Locator In Selenium<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>CSS Locator in Selenium is one of the most important aspects of writing a script. If you cannot locate an element by using any CSS locator in Selenium, then being proficient at Selenium automation will be a tough task. Selenium provides multiple ways of locating an element. You can check out other articles around different &hellip;<\/p>\n","protected":false},"author":86855,"featured_media":231,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[287],"class_list":["post-93311","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-selenium"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Selenium Java Tutorial \u2013 Class Name Locator In Selenium - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Class Name Locator? Check our article explaining how you can locate an element by using any CSS locator in Selenium\" \/>\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.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Selenium Java Tutorial \u2013 Class Name Locator In Selenium - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Class Name Locator? Check our article explaining how you can locate an element by using any CSS locator in Selenium\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-21T08:25:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sadhvi Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sadhvi Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html\"},\"author\":{\"name\":\"Sadhvi Singh\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c161d28b654426f5f53205d3e5741592\"},\"headline\":\"Selenium Java Tutorial \u2013 Class Name Locator In Selenium\",\"datePublished\":\"2019-06-21T08:25:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html\"},\"wordCount\":847,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"keywords\":[\"Selenium\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html\",\"name\":\"Selenium Java Tutorial \u2013 Class Name Locator In Selenium - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"datePublished\":\"2019-06-21T08:25:42+00:00\",\"description\":\"Interested to learn about Class Name Locator? Check our article explaining how you can locate an element by using any CSS locator in Selenium\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/06\\\/selenium-java-tutorial-class-name-locator-selenium.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Selenium Java Tutorial \u2013 Class Name Locator In Selenium\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c161d28b654426f5f53205d3e5741592\",\"name\":\"Sadhvi Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g\",\"caption\":\"Sadhvi Singh\"},\"description\":\"Sadhvi Singh is a QA Manager. In 7 years of her professional journey, she has worked on multiple domains and testing techniques like Automation testing, Database testing, API testing, Manual testing, and Security testing. With multiple tools exposure added to her experience, she has skilled herself further through her two major accolades at International level through ISTQB with foundation and advanced levels. She has a technical blog named as qavibes.blogspot.com where she caters to all the challenges offered in the day to day journey of the quality assurance aspirants. In her spare time, she also works as a technical trainer and mentor to many budding QA professionals.\",\"sameAs\":[\"https:\\\/\\\/www.lambdatest.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/sadhvi-singh\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Selenium Java Tutorial \u2013 Class Name Locator In Selenium - Java Code Geeks","description":"Interested to learn about Class Name Locator? Check our article explaining how you can locate an element by using any CSS locator in Selenium","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.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html","og_locale":"en_US","og_type":"article","og_title":"Selenium Java Tutorial \u2013 Class Name Locator In Selenium - Java Code Geeks","og_description":"Interested to learn about Class Name Locator? Check our article explaining how you can locate an element by using any CSS locator in Selenium","og_url":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-06-21T08:25:42+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","type":"image\/jpeg"}],"author":"Sadhvi Singh","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Sadhvi Singh","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html"},"author":{"name":"Sadhvi Singh","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c161d28b654426f5f53205d3e5741592"},"headline":"Selenium Java Tutorial \u2013 Class Name Locator In Selenium","datePublished":"2019-06-21T08:25:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html"},"wordCount":847,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","keywords":["Selenium"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html","url":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html","name":"Selenium Java Tutorial \u2013 Class Name Locator In Selenium - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","datePublished":"2019-06-21T08:25:42+00:00","description":"Interested to learn about Class Name Locator? Check our article explaining how you can locate an element by using any CSS locator in Selenium","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/06\/selenium-java-tutorial-class-name-locator-selenium.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Selenium Java Tutorial \u2013 Class Name Locator In Selenium"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c161d28b654426f5f53205d3e5741592","name":"Sadhvi Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g","caption":"Sadhvi Singh"},"description":"Sadhvi Singh is a QA Manager. In 7 years of her professional journey, she has worked on multiple domains and testing techniques like Automation testing, Database testing, API testing, Manual testing, and Security testing. With multiple tools exposure added to her experience, she has skilled herself further through her two major accolades at International level through ISTQB with foundation and advanced levels. She has a technical blog named as qavibes.blogspot.com where she caters to all the challenges offered in the day to day journey of the quality assurance aspirants. In her spare time, she also works as a technical trainer and mentor to many budding QA professionals.","sameAs":["https:\/\/www.lambdatest.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/sadhvi-singh"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/93311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/86855"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=93311"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/93311\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/231"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=93311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=93311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=93311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}