Copy the below mentioned script and execute in your system.eval(ez_write_tag([[728,90],'softwaretestingmaterial_com-large-leaderboard-2','ezslot_4',650,'0','0'])); If multiple elements have the same HTML tag and attribute, then the first one will be recognized. CSS Selectors: Different Types of Selenium Locators There is a distinct range of web elements such as text box, check box, drop down menu, radio button, etc. Copy the below mentioned script and execute in your system. Follow the below screenshot to do so. Locating an element on the web page can be challenging, especially in the current scenarios, where every other web page is dynamically programmed and creates/renders the web elements on a need basis dynamically. Take a note of its Tag and ID. “How To Locate Element By ID Locator”2. If we have a ul and we want to select its fourth li element without regard to any other elements, we should use nth-child or nth-of-type. Explanation: ‘div#buttonDiv>button’ will first go to div element with id ‘buttonDiv’ and then select its child element – ‘button’eval(ez_write_tag([[970,250],'softwaretestingmaterial_com-mobile-leaderboard-1','ezslot_17',661,'0','0'])); Explanation: ‘div#buttonDiv button’ will first go to div element with id ‘buttonDiv’ and then select ‘button’ element inside it (which may be its child or sub child), To locate the element with text ‘QTP’, we have to use “nth-of-type”, Similarly, To select the last child element, i.e. If you have any queries by finding elements using CSS Selector Selenium, please comment below in the comment section. In this post, I will show you how to find element locators using CSS without using any tools like Firebug or Firepath. Essentially, theCSS Selector combines an element selector and a selector value that can identify particular elements on a web page. It makes finding a unique static attribute for a dynamic element quite tricky. In the previous post, we have seen “locators in Selenium“. It acts in the same way of locating elements using CSS selectors with the same tag and class. “How To Locate Element By Tag Name Locator”5. Follow the below screenshot to do so. Like XPath, CSS selector can be used to locate web elements without ID, class or Name. different types of Locators in Selenium IDE There are commands that do not need a locator (such as the \"open\" command Most of the automation testers believe that using CSS selectors makes the execution of script faster compared to XPath locator. In the previous post, we have seen “locators in Selenium“. Subscribe and get popular blog posts about software testing industry. “How To Locate Element By ID Locator” 2. CSS selectors for Selenium with example Home >> Selenium Tutorials >> CSS selectors for Selenium with example When we don't have an option to choose Id or Name, we should prefer using CSS locators as the best alternative. Don’t forget to share it!eval(ez_write_tag([[300,250],'softwaretestingmaterial_com-leader-4','ezslot_16',663,'0','0'])); Here are few hand-picked articles for you to read next: Get our latest blog posts delivered to your inbox.