• Re" />
    • Re" />
      • Re"/>
        DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        selenium webdriver to find the anchor tag and click that

        76k Views Asked by Sathish Kumar k k At 27 May 2012 at 12:23 2025-12-10T14:50:22.070571
        <div id="ContentPrimary">
        <ul class="selectors modeSelectors">
            <li><a href="/content/l411846326l1213g/references/" title="">
                <span class="selector">References (27)</span></a></li>
            <li><a href="/content/l411846326l1213g/referrers/" title="">
                <span class="selector">Cited By (2)</span></a></li>
            <li><a href="/content/l411846326l1213g/export-citation/" title="">
                <span class="selector">Export Citation</span></a></li>
            <li><a href="/content/l411846326l1213g/about/" title="">
                <span class="selector">About</span></a></li>
        </ul>
        

        In this I need to find and click About link using Selenium api but I was unable to do it.

        what I did is

        wait.until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver webDriver) {
                System.out.println("Searching ...");
                String s = driver.findElement(By.cssSelector("#ContentPrimary ul li[4] span.selector")).getText();
                System.out.println(s);
                if (Pattern.compile(Pattern.quote("About"), Pattern.CASE_INSENSITIVE).matcher(s).find()) {
                    return true;
                } else {
                    return false;
                }
            }
        });
        driver.findElement(By.linkText("About")).click();
        

        but its not working

        java selenium web-scraping web-scripting
        Original Q&A
        3

        There are 3 best solutions below

        4
        devsnd devsnd On 27 May 2012 at 12:34 BEST ANSWER

        In my experience the Selenium API has many flaws in that way. They can mostly only be overcome by reformulating your selectors. For example you could try using a XPath selector to get your element:

        driver.findElement(By.xpath("//a[contains(.,'About')]")).click();
        

        Also, if you are trying to use the Internet Explorer it might help not to click the element, but instead to simulate pushing the Enter button. So assumung the Element is found, you could try this:

        driver.findElement(By.linkText("About")).sendKeys(Keys.ENTER);
        
        1
        Aleh Douhi Aleh Douhi On 27 May 2012 at 12:56

        You can use ExpectedConditions:

        wait.until(visibilityOfElementLocated(By.linkText("About"))).click();
        
        0
        Thakhani Tharage Thakhani Tharage On 26 April 2023 at 04:59

        Try using xpath to find the ancor then use that object to send an enter key

        anchorObj.sendKeys(Keys.ENTER);

        Related Questions in JAVA

        • Add image to JCheckBoxMenuItem
        • How to access invisible Unordered List element with Selenium WebDriver using Java
        • Inheritance in Java, apparent type vs actual type
        • Java catch the ball Game
        • Access objects variable & method by name
        • GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
        • Perform a task each interval
        • Compound classes stored in an array are not accessible in selenium java
        • How to avoid concurrent access to a resource?
        • Why does processing goes slower on implementing try catch block in java?
        • Redirect inside java interceptor
        • Push toolbar content below statusbar
        • Animation in Java on top of JPanel
        • JPA - How to query with a LIKE operator in combination with an AttributeConverter
        • Java Assign a Value to an array cell

        Related Questions in SELENIUM

        • How to access invisible Unordered List element with Selenium WebDriver using Java
        • Compound classes stored in an array are not accessible in selenium java
        • Fail Upload file in Selenium webdriver using Robot class
        • Selenium crashes Firefox, how to reset the used profile / where is the default profile?
        • Selenium Driver Service not found exception
        • Unable to read excel if cell/column has drop down list enabled for Selenium webdriver TestNG
        • Selenium C#: Store element's position on graph as a variable
        • Selenium webdriver for handling dynamic ckeditors
        • What can cause `UnreachableBrowserException: Could not start a new session`?
        • Click on the 'compose' button in gmail inbox page
        • python - selenium change frame not working
        • Selecting Options from a Drop Down Menu in C# using Selenium
        • Validation without skipping the test cases if one fails
        • How can i increase session timeout (which is 30 minutes by default)
        • Load additional CONFIG file with values

        Related Questions in WEB-SCRAPING

        • Scraping location data in rvest
        • Python Beautiful Soup Table Data Scraping Specific TD Tags
        • VBA: Extract HTML from new page (same url)
        • Nokogiri how to traverse every row of a table with two classes
        • URL Variable is not being recognized using NSURL
        • Scrapy CrawlSpider not following links
        • Scraping blog and saving date to database causes DateError: unknown date format
        • Can Nokogiri interpret javascript? - Web Scraping
        • Beautifulsoup: Getting a new line when I tried to access the soup.head.next_sibling value with Beautifulsoup4
        • Web scraping with python and selenium
        • getting specific images from page
        • Why does Selenium return the source of the previously loaded page in Python?
        • R 3.1.3 How to Scrape Multiple City-Data.com Records?
        • How to eliminate certain elements when scraping?
        • Parse an HTML table with Nokogiri in Ruby

        Related Questions in WEB-SCRIPTING

        • automatically assign my uploaded document to a content type
        • Alfresco- Pass variable values from js controller to freemarker
        • Can't create appropriate selector to grab names
        • How to use Web Script in Alfresco as a developer?
        • Add in 'if' clause using beautifulSoup
        • I'm learning python and am interested in using it for web-scripting. What frameworkes are out there and do I need one?
        • how to get user spaces using Webscript in alfresco
        • How to make iMacro find only the exact string in a TXT attribute
        • Calling an external rest service from Alfresco Share page
        • download google.visualisation charts as an image file
        • IOT based queue management system with nodeMcu (esp8266)
        • Lucene search to find either of 2 particular content model types within a folder
        • selenium webdriver to find the anchor tag and click that
        • is it possible to receive Dom in google webscript?
        • How do I fill in and submit a form on another website with axios?

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?
        .

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Math
        • Aftereffectstemplates