angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

clear() is not working on number inputs in Windows with Chrome V74 #5228

Open sborland opened 5 years ago

sborland commented 5 years ago

Hi 👋 First time opening an issue here, hopefully I'm formatting this right. I have a strange issue that I can replicate on my coworker Window's box and my Windows VM but not on my Mac (High Sierra v10.13.6).

My input isn't being cleared when using clear() and I use it like in the example below. It's only on inputs that have type="number" and I was only able to replicate it on Windows. I don't see any errors pop up either. It was working last week when Chrome was on v73 and chromedriver was on 2.46 but since the update, we've been trying to figure it out to not much success.

var foo = element(by.id('foo'));
foo.clear();

If it matters, the selenium version is at 3.141.59 chromedriver is at v74.0.3729.6

cnishina commented 5 years ago

Have you tried ChromeDriver 74?

fontiago commented 5 years ago

As mentioned, we're using ChromeDriver v74.0.3729.6 which is where we're seeing the issue. 2.37 works just fine for me on windows but the newest ChromeDriver does not.

cnishina commented 5 years ago

Ah I missed that part. So just from the information provided, this does not appear to be a Protractor framework issue but rather an issue with ChromeDriver itself.

If it is only happening on Windows and not on Mac, then this should be a bug against ChromeDriver. http://chromedriver.chromium.org/help and https://bugs.chromium.org/p/chromedriver/issues/list

Just for more context, could you also let me know how you are running these two lines of code? What does your config look like?

sborland commented 5 years ago

Thanks for the links!

We are just running it in regular spec files. We have helper functions to log in and navigate. So basically, a reduced version of the spec is this:

describe('check filters', function () {
  beforeAll(function () {
    pageControl.login();
    pageControl.goToDevices();
  });
  afterAll(function () {
    pageControl.logout();
  });
   it('can filter by vulnerable devices', function () {
      devicePage.filterByVulnerableDevices(0);
      expect(devicePage.getNumberOfDevices()).toEqual(0);
  });
});

and in filterByVulnerableDevices:

vulnerableDevicesInput =  $('.filter-vulDevices');
.
.
.
 filterByVulnerableDevices = function(numberOfVulnerableDevices) {
      vulnerableDevicesInput.clear();
      vulnerableDevicesInput.sendKeys(numberOfVulnerableDevices, protractor.Key.ENTER);
  };

The input field for vulnerable devices defaults to value 1, so we have to clear it first before we input a value. What ends up happening is that the input field doesn't clear, and it adds the 0 to the input, setting the value to 10.

Here's our config:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  framework: 'jasmine2',
  resultJsonOutputFile: suitesDir + '/test-results/result.json',

  multiCapabilities: [
      {
      browserName: 'chrome',
      'chromeOptions': {
          args: ['--test-type', 'incognito=true', 'start-maximized']
      }}
    ],

  suites: getSuites(),

  allScriptsTimeout: 120000,

  getPageTimeout: 120000,

  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 1200000,
    isVerbose: false,
    realtimeFailure: true
  },

  beforeLaunch: function() {
    return new Promise(function(resolve){
      reporter.beforeLaunch(resolve);
    });
  },

  onPrepare: function() {
    jasmine.getEnv().addReporter(reporter);
    jasmine.getEnv().addReporter(junitReporter);
    jasmine.getEnv().addReporter(new jasmineSpecReporter());
  },

  afterLaunch: function(exitCode) {
    return new Promise(function(resolve){
      reporter.afterLaunch(resolve.bind(this, exitCode));
    });
  }

};
IgorSasovets commented 5 years ago

@sborland , could you please share some example spec that I could run on my machine? I mean using publicly available application.