mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.1k stars 1.52k forks source link

BUG: Text transformation issue with `text-transform: capitalize;` using Selenium WebDriver with Firefox 127.0.2 #2185

Open Usielrivas opened 1 month ago

Usielrivas commented 1 month ago

Description: There is an issue with the text-transform: capitalize; CSS property when using Selenium WebDriver with Firefox 127.0.2. The text transformation does not handle accented characters correctly, resulting in incorrect capitalization.

Steps to Reproduce:

  1. Install Node.js.
  2. Create a new project and install Selenium WebDriver.
    npm init -y
    npm install selenium-webdriver // last version
  3. Download geckodriver 0.34 and place it in a specific directory.
  4. Create the following JavaScript script (selenium_example.js):
const { Builder, By, until } = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
const path = require('path');

const geckodriverPath = path.join(process.env.HOME, 'gecko/geckodriver');  // Adjust this path

(async function example() {
    let options = new firefox.Options();
    options.setBinary(geckodriverPath);

    let driver = new Builder()
        .forBrowser('firefox')
        .setFirefoxOptions(options)
        .build();

    try {
        const url = 'file:///home/user/test/bug/index.html';

        await driver.get(url);

        await driver.wait(until.elementLocated(By.tagName('h1')), 10000);

        let element = await driver.findElement(By.tagName('h1'));

        let text = await element.getText();

        console.log(`response: ${text}`);
    } finally {
        await driver.quit();
    }
})();
  1. Create the following HTML file (index.html):
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Bug Test</title>
    <style>
        h1 {
            text-transform: capitalize;
        }
    </style>
</head>
<body>
    <h1>Fecha de expiración</h1>
</body>
</html>
  1. Run the script:
    node selenium_example.js

Expected Behavior: The output should be:

response: Fecha De Expiración

Actual Behavior: The output is:

response: Fecha De ExpiraciÓN

Additional Information:

This issue started occurring after updating to Firefox 127.0.2. It appears that the text-transform: capitalize; CSS property does not handle accented characters correctly.

Console Output: No errors in the console.


whimboo commented 1 month ago

In Firefox 127 we landed a fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1888004. That included an update of the Selenium atoms for 'getVisibleText' to revision 33c6b7841a59aaaad55744909c0600f066fd5593. This update includes the changes from https://github.com/SeleniumHQ/selenium/pull/13792.

@diemol could your patch have caused a regression for this atom and behavior for text-transform: capitalize?

diemol commented 1 month ago

But @whimboo... I applied the patch because you asked for it 🤣

https://github.com/SeleniumHQ/selenium/pull/13792

So I do not know; tests were passing, so I think it was all good. Did we miss something?

whimboo commented 1 month ago

There might have been a misunderstanding at that time, and I apologize for that. The change I proposed was only relevant to my case, and I didn't test any other scenarios. I assume there is no test in the Selenium code base that checks for accented characters, which would have caught this regression.

As it looks like we should file a new issue on the Selenium repository to get this issue fixed. @Usielrivas because you found the issue would you like to do that?

Usielrivas commented 1 month ago

Fact reported in selenium https://github.com/SeleniumHQ/selenium/issues/14271