TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Selenium

    Find elements using Selenium Locators

    Overview

    In this tutorial, we will discuss about finding elements on a web page using Selenium Locators. By is the locating mechanism to find element(s)  on a web page using locators.

    We can locate web elements in Selenium with the help of methods like:

    • driver.findElement()
    • driver.findElements()

    The first method is used to find a single element on the page. The second method is mostly used to find multiple elements.

    Types of Locators

    https://www.testingdocs.com/different-types-of-locators-in-selenium-webdriver/

    We will look at close some of the locators supported by Selenium.

    By.id()

    https://www.testingdocs.com/selenium-find-element-using-by-id-attribute/

    By.name()

    https://www.testingdocs.com/selenium-find-element-using-by-name-example/

    By.tagName()

    https://www.testingdocs.com/locate-elements-by-tagname-in-selenium-webdriver/

    LinkText : By.linkText()

    https://www.testingdocs.com/find-link-using-by-linktext-in-selenium/

    By.partialLinkText()

    https://www.testingdocs.com/find-links-using-by-partial-link-text-in-selenium/

    By.className()

    Code :

    WebElement element = findElement(By.className(“b_searchbox”));

    By.cssSelector()

    CSS locator mechanism can be used to identify web elements. CSS executes faster than XPath. CSS locator uses CSS selectors to find the elements in the webpage.

    For example, the following statement first locates a web element satisfying the selector pattern

    div#searchBox {text-align: center;}

    WebElement search = driver.findElement(By.cssSelector(“div#searchBox”));

    XPath : By.xpath()

    https://www.testingdocs.com/find-elements-by-xpath-in-selenium/

     

    —

    Selenium Tutorials on this website:

    https://www.testingdocs.com/selenium-webdriver-tutorial/

    Official Website:

    https://www.selenium.dev/

    Related Posts

    Windows 10 Settings

    Selenium /

    Add Microsoft Webdriver on Windows OS

    Download Selenium Components

    Selenium /

    Getting Started with Selenium Webdriver

    LambdaTest Testing Cloud SaaS Platform

    Selenium /

    LambdaTest – Testing Cloud SaaS Platform

    Selenium /

    Selenium 3.0 and Mozilla GeckoDriver

    SauceLabs Website

    Selenium /

    Run an Example Test on SauceLabs

    ‹ RemoteWebDriver Tutorial› Selenium WebDriver Questions

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com