Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:27:01+00:00 2026-06-11T10:27:01+00:00

Is it possible to find links on a webpage by searching their text using

  • 0

Is it possible to find links on a webpage by searching their text using a pattern like A-ZNN:NN:NN:NN, where N is a single digit (0-9).

I’ve used Regex in PHP to turn text into links, so I was wondering if it’s possible to use this sort of filter in Selenium with C# to find links that will all look the same, following a certain format.

I tried:

driver.FindElements(By.LinkText("[A-Z][0-9]{2}):([0-9]{2}):([0-9]{2}):([0-9]{2}")).ToList();

But this didn’t work. Any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:27:02+00:00Added an answer on June 11, 2026 at 10:27 am

    In a word, no, none of the FindElement() strategies support using regular expressions for finding elements. The simplest way to do this would be to use FindElements() to find all of the links on the page, and match their .Text property to your regular expression.

    Note though that if clicking on the link navigates to a new page in the same browser window (i.e., does not open a new browser window when clicking on the link), you’ll need to capture the exact text of all of the links you’d like to click on for later use. I mention this because if you try to hold onto the references to the elements found during your initial FindElements() call, they will be stale after you click on the first one. If this is your scenario, the code might look something like this:

    // WARNING: Untested code written from memory. 
    // Not guaranteed to be exactly correct.
    List<string> matchingLinks = new List<string>();
    
    // Assume "driver" is a valid IWebDriver.
    ReadOnlyCollection<IWebElement> links = driver.FindElements(By.TagName("a"));
    
    // You could probably use LINQ to simplify this, but here is
    // the foreach solution
    foreach(IWebElement link in links)
    {
        string text = link.Text;
        if (Regex.IsMatch("your Regex here", text))
        {
            matchingLinks.Add(text);
        }
    }
    
    foreach(string linkText in matchingLinks)
    {
        IWebElement element = driver.FindElement(By.LinkText(linkText));
        element.Click();
        // do stuff on the page navigated to
        driver.Navigate().Back();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Find text string using jQuery? How do you find a text string
I'd like to find (using javascript) all of the references to image links on
Is it possible to find the database technology using for a website. eg. www.example.com/
Is it possible to find and replace in selected text in Snow Leopard Xcode
Is it possible to build a GUI using platform-native code, like Cocoa, in QT?
Possible Duplicate: How do I linkify text using ActionScript 3 I am using a
Is it possible to find all the pages and links on ANY given website?
Back in the days :) it was possible to find out which links where
Is it possible using jQuery to select all <a> links which href ends with
Hey all, I would like to make possible to share links of my website

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.