SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.7k stars 8.19k forks source link

.sendKeys() throws ENAMETOOLONG with long strings in Chrome v68 on OSX #6343

Closed djom202 closed 2 years ago

djom202 commented 6 years ago

Meta

OS: OSX 10.13.6

Selenium Version: 2.53.2

Browser: Chrome

Browser Version: v68.0.3 (64-bit)

Command

The text is generated randomly by chancejs

element(by.css('.class-name')).clear().sendKeys(
   'Faseazo athem hib neftikeb ri he bejzog siw lupruwwah tak ka fuzdujif. Pegizliw berik bit otif bunma vobezol te talgico liude ev ajupazos fewe vupfewif ezaniw rioghu ciszap hahomor memjudiz. Feog von aba buosif riji negal gembini mug gife giw kiho guwlegom za hasuj judtid aci.'
);

Expected Behavior

The string is input into a textarea in Chrome v68 on OSX without any issues.

Actual Behavior

sendKeys throws ENAMETOOLONG if the string is input all at once. It seems as if the textarea in the OSX Chrome webdriver is being treated like an input of type=text.

Steps to reproduce

Using nodejs generate a large string (>300 chars) s and call .sendKeys(s) on a textarea or input

This testcase triggers the failure on my local machine and on BrowserStack.

Issue related by #2164

Error description

Error: ENAMETOOLONG: name too long, stat 'Faseazo athem hib neftikeb ri he bejzog siw lupruwwah tak ka fuzdujif. Pegizliw berik bit otif bunma vobezol te talgico liude ev ajupazos fewe vupfewif ezaniw rioghu ciszap hahomor memjudiz. Feog von aba buosif riji negal gembini mug gife giw kiho guwlegom za hasuj judtid aci.'
    at Error (native)
From: Task: WebElement.sendKeys()
    at WebElement.sendKeys (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/webdriver.js:2185:43)
    at actionFn (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:89:44)
    at Array.map (native)
    at actionResults.getWebElements.then (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:461:65)
    at ManagedPromise.invokeCallback_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:1376:14)
    at TaskQueue.execute_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:3084:14)
    at TaskQueue.executeNext_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:3067:27)
    at asyncRun (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:2927:27)
    at /var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:668:7
    at process._tickCallback (internal/process/next_tick.js:109:7)Error
    at ElementArrayFinder.applyAction_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:459:27)
    at ElementArrayFinder.(anonymous function) [as sendKeys] (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:91:29)
    at ElementFinder.(anonymous function) [as sendKeys] (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:831:22)
    at /var/lib/jenkins/workspace/surveyMaking/support/helpers/maker.js:866:66
    at elementArrayFinder_.then (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:804:32)
    at ManagedPromise.invokeCallback_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:1376:14)
    at TaskQueue.execute_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:3084:14)
    at TaskQueue.executeNext_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:3067:27)
    at asyncRun (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:2927:27)
    at /var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:668:7Error
    at ElementArrayFinder.applyAction_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:459:27)
    at ElementArrayFinder.(anonymous function) [as getAttribute] (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:91:29)
    at ElementFinder.(anonymous function) [as getAttribute] (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:831:22)
    at /var/lib/jenkins/workspace/surveyMaking/support/helpers/maker.js:868:5
    at elementArrayFinder_.then (/var/lib/jenkins/workspace/surveyMaking/node_modules/protractor/built/element.js:804:32)
    at ManagedPromise.invokeCallback_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:1376:14)
    at TaskQueue.execute_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:3084:14)
    at TaskQueue.executeNext_ (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:3067:27)
    at asyncRun (/var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:2927:27)
    at /var/lib/jenkins/workspace/surveyMaking/node_modules/selenium-webdriver/lib/promise.js:668:7
Xotabu4 commented 5 years ago

Wrote my workaround for this:

            // BUG: https://github.com/SeleniumHQ/selenium/issues/6343
            // Cannot send long strings
            if (text.length >= 250) {
                const chunks = options.message.match(/.{1,250}/g)
                await Promise.all(
                    chunks.map(async chunk => {
                        await browser.sleep(100)
                        await $('input').sendKeys(chunk)
                    })
                )
            } else {
                await this.chatMessageTextArea.sendKeys(text)
            }
djom202 commented 5 years ago

@Xotabu4 Looks great, let me implement it, but I think is going to work fine. Thanks.

rootux commented 4 years ago

It's not clear as for some cases with a lot of line breaks - 250 chars limit is not enough

potapovDim commented 3 years ago

@barancev @JS31096 seems like you can close this issue, i cannot reproduce

mrkjdy commented 3 years ago

I am getting an ENAMETOOLONG error for .sendKeys() with long messages on selenium 4 using docker

potapovDim commented 3 years ago

@mrkjdy can yo provide an example of the string ?

mrkjdy commented 3 years ago

Here's the error output that I get:

- Failed: ENAMETOOLONG: name too long, stat 'long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample - long text sample'
        From: Task: WebElement.sendKeys()
            at WebElement.sendKeys (/Users/markjudy/Desktop/e2e-test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:2185:43)

Also, it only happens if I have a FileDetector set

titusfortner commented 2 years ago

Right, when you have a file detector set, it's first going to try to parse the string to see if it is a file, and since file length is limited to 255 the OS library is throwing an error.

Maybe it would make sense to add a conditional to check if the size is >255 and treat it as if there were no file detector...

Anyone want to make a PR right around here: https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/lib/webdriver.js#L2533

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.