Skip to content

By.LinkText doesn't work with elements having text-transform:capitalize style #884

@romovs

Description

@romovs

Selenium fails to find elements which have "text-transform:capitalize" style applied.
Please see the test case below. Selenium finds elements which have "uppercase" and "lowercase" or no transformations successfully, but fails on "capitalize".

Tested with Selenium v2.45.0 (C#). Chrome/FF, Windows/Linux

Example html:

<html>
    <head></head>
    <body>
        <a href="#" id="upper" style="text-transform:uppercase;">Hello world! foo-bar-BAZ</a><br/>
        <a href="#" id="lower" style="text-transform:lowercase;">Hello world! foo-bar-BAZ</a><br/>
        <a href="#" id="capital" style="text-transform:capitalize;">Hello world! foo-bar-BAZ</a><br/>
        <a href="#" id="none">Hello world! foo-bar-BAZ</a>
    </body>
</html>

The transformed text looks like this:

HELLO WORLD! FOO-BAR-BAZ
hello world! foo-bar-baz
Hello World! Foo-Bar-BAZ
Hello world! foo-bar-BAZ

Example test:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace SeleniumLinkTest
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl("http://localhost");

                var upper = driver.FindElement(By.LinkText("HELLO WORLD! FOO-BAR-BAZ"));
                var lower = driver.FindElement(By.LinkText("hello world! foo-bar-baz"));
                var capital = driver.FindElement(By.LinkText("Hello World! Foo-Bar-BAZ")); // fails with NoSuchElementException
                var none = driver.FindElement(By.LinkText("Hello world! foo-bar-BAZ"));
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-atomsJavaScript chunks generated by Google closure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions