The Selenium webdriver can be used to obtain an element’s CSS class name. The getAttribute() method is used to get the class name attribute of an element in an HTML document. The class value is then supplied to the method as a parameter.