protractor icon indicating copy to clipboard operation
protractor copied to clipboard

browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); not working for chrome, macOS

Open rahmansa2010 opened this issue 7 years ago • 3 comments

Hi there!

Thanks for submitting an issue to Protractor.

Bug report When trying to use Key Stroke for ESCAPE button in protractor its not dismissing the window (native window to browse hard disc to find file location)

  • Node Version: 10.15.0
  • Protractor Version: 5.4.2
  • Angular Version: ``
  • Browser(s): Chrome 72.0
  • Operating System and Version Mac Os Mojave
  • Your protractor configuration file

exports.config = { directConnect: true, multiCapabilities:[{ browserName:'chrome', //chromeOptions: {args: ['--headless']} //headlessmode }, ], specs: ['../test_specs/rough/fileuploadtest.js'], jasmineNodeOpts:{ defaultTimeoutInterval:30000, includeStackTrace:true, showColors:true }, };

  • A relevant example test

    var protractor=require ("protractor");

it('Upload file test 2',function () {

    browser.ignoreSynchronization=true;
    browser.get('https://cgi-lib.berkeley.edu/ex/fup.html');

    element(by.xpath("//input[@name='upfile']")).click().then(function () {
        browser.sleep(4000);
        browser.actions().sendKeys(protractor.Key.ESCAPE).perform();

    });

});
  • Output from running the test Escape button is not dismissing the native window it just opened to browse the hard disc.

  • Steps to reproduce the bug: Run the test pls

  • The URL you are running your tests against (if relevant)

Feature Request

  • Reasons for adopting new feature
  • Is this a breaking change? (How will this affect existing functionality) https://cgi-lib.berkeley.edu/ex/fup.html

rahmansa2010 avatar Mar 06 '19 04:03 rahmansa2010

Webdriver does not support the file upload window in any fashion. You should not click the upload button under any circumstances. If you need to upload a file, you should use sendKeys() to send your file path directly to the file upload element.

You can't interact with the native OS file browser dialog directly, but we do some magic so that if you call WebElement#sendKeys("/path/to/file") on a file upload element, it does the right thing. Make sure you don't WebElement#click() the file upload element, or the browser will probably hang.

ben-yocum avatar Mar 08 '19 21:03 ben-yocum

ESC button for Mac was not working with protractor - know issue.

rahmansa2010 avatar Jan 14 '21 20:01 rahmansa2010

$('body').sendKeys(protractor.Key.ARROW_UP+protractor.Key.ARROW_UP+protractor.Key.ARROW_UP);

A-Kavin avatar Jul 23 '21 04:07 A-Kavin