Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to click on a specific link which is inside element based on multiple pages and if not found click on “next” pagination link in Selenium?

    How to click on a specific link which is inside element based on multiple pages and if not found click on “next” pagination link in Selenium?

    May 7, 2024

    How to click on a link that is under a table element, but that is not visible on first page. There are pagination links “previous” & “next” on the page, and i want to iterate over multiple pages and find my link “a” tag based on Link text.

    if link matches the string, then only click on the link, otherwise keep clicking “Next” in the pagination.

    List<WebElement> links = driver.findElements(By.tagName(“a”));
    int size = links.size();

    for (int i = 0; i < size; i++) {
    if (links.get(i).getText().equalsIgnoreCase(LinkMatchValue)) {
    driver.findElement(By.xpath(“//a[contains(text(),'” + LinkMatchValue+ “‘)]”)).click();

    } else {
    driver.findElement(By.linkText(“next”)).click();

    }

    }

    ==================================================================================

    <table id=”table1″>
    <thead>
    <tr>
    </td>
    </tr><tr class=”classA”>
    <td><a href=…”>Link 1</a></td>
    </tr>
    <td><a href=…”>Link 1</a></td></tr><tr class=”even”>
    <td><a href=…”>Link 2</a></td></tr><tr class=”even”>
    <td><a href=…”>Link 3</a></td></tr><tr class=”even”>
    <td><a href=…”>Link 4</a></td></tr><tr class=”even”>
    <td><a href=…”>Link 5</a></td></tr><tr class=”even”>
    <td><a href=…”>Link 6</a></td></tr><tr class=”even”>
    </tbody>
    </table>

    Source: Read More

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleAutomated contract data extraction: A complete guide
    Next Article Importance of Retail Analytics in the eCommerce Industry

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 17, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-40906 – MongoDB BSON Serialization BSON::XS Multiple Vulnerabilities

    May 17, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    Slay in style with RTX 50-series DOOM: The Dark Ages PCs, laptops, and GPUs you could get free — act fast before the giveaways end

    News & Updates

    Accelerating insurance policy reviews with generative AI: Verisk’s Mozart companion

    Machine Learning

    INTERPOL Arrests 306 Suspects, Seizes 1,842 Devices in Cross-Border Cybercrime Bust

    Development

    OneDrive and SharePoint users can now connect their files to ChatGPT’s Deep Research

    Operating Systems
    GetResponse

    Highlights

    Development

    Apple becomes the world’s most valuable company (again) ahead of Microsoft after recently unveiling its AI strategy

    June 12, 2024

    Apple’s stock price surged by 3% after its big AI event, making it the world’s…

    Malware Delivery via Cloud Services Exploits Unicode Trick to Deceive Users

    May 21, 2024

    GSMA Confirms End-to-End Encryption for RCS, Enabling Secure Cross-Platform Messaging

    March 16, 2025

    DELTA: A Novel AI Method that Efficiently (10x Faster) Tracks Every Pixel in 3D Space from Monocular Videos

    November 6, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.