Skip to content
This repository has been archived by the owner. It is now read-only.

Linux Chrome driver on Sauce Labs causes spurious test failures #1329

Closed
karlht opened this issue Jun 27, 2014 · 10 comments
Closed

Linux Chrome driver on Sauce Labs causes spurious test failures #1329

karlht opened this issue Jun 27, 2014 · 10 comments
Assignees
Labels

Comments

@karlht
Copy link

@karlht karlht commented Jun 27, 2014

[Another Webdriver/Sauce problem.]

Running the test through a local Selenium/Webdriver works fine; running it on Sauce causes the error shown in the image below:

0007screenshot

Test script is at https://github.com/karlht/services-tools/blob/master/fxa-webdriver-tests/multi123done.py -- results on Sauce are at https://saucelabs.com/tests/aa73da25fd354712903132015e5d50ca

Between this and #1324, I'm prepared to declare Sauce tests as 'nice for a first pass at possible problems, but not definitive' -- they require local and/or manual verification too much of the time.

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Jun 27, 2014

See theintern/intern#210

Nevermind, that's a different thing.

@pdehaan pdehaan added the tests label Jun 28, 2014
@pdehaan pdehaan added this to the train-17 (Jul 14) milestone Jun 30, 2014
@ckarlof ckarlof modified the milestones: 2014 Q3 (Sep 30), train-17 (Jul 14), z-later Jul 11, 2014
@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Jul 29, 2014

@shane-tomlinson This is caused by our autofocus logic in the BaseView.
image

Is force autofocus logic only for IE < 10? Can we disable it for other browsers?

@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Jul 29, 2014

@vladikoff - the autofocus logic is for Firefox, Chrome, and IE. Browsers usually only autofocus an element if the element is in the DOM before DOMContentLoaded. You can see the default browser behavior by commending out the attemptFocus on line 245 of base.js.

  • Firefox: no autofocus happens, ever.
  • Chrome: only the first page has an element focused.
  • Safari: sane.
  • Opera: sane.
  • IE11: only the first page has an element focused.
@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Jul 29, 2014

@karlht - can you copy over a log so we have a record of it and can use it to debug?

@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Jul 29, 2014

@karlht - do the elements need to be focused before you send off key strokes to them?

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Jul 29, 2014

can you copy over a log so we have a record of it and can use it to debug? - do the elements need to be focused before you send off key strokes to them?

No need for the logs. I've already researched this problem over the last few days. Removing attemptFocus from BaseView gives me 100% functional pass in ChromeDriver.

Here is a more detailed description with screenshots of what happens on SauceLabs or locally in Chrome: theintern/leadfoot#6

The ChromeDriver is a lot faster than the autofocus logic and autofocus causes the typing to fail.
We need to either 1. disable the autofocusing for functional tests or 2. disable that autofocusing for Chrome. 3. remove attemptFocus, I guess this might not be an option.

@karlht
Copy link
Author

@karlht karlht commented Jul 29, 2014

I'm in a laptops-closed QA work-week today, but I'll get a log copied over as soon as I can.

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Jul 29, 2014

@karlht see my above comment. Don't worry about the logs. Enjoy the work week :)

@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Jul 29, 2014

The ChromeDriver is a lot faster than the autofocus logic and autofocus causes the typing to fail.
We need to either 1. disable the autofocusing for functional tests or 2. disable that autofocusing for Chrome. 3. remove attemptFocus, I guess this might not be an option.

I'm confused - what is the actual problem? Does the ChromeDriver enter in keyboard input and then we try to focus the element after some input has already been entered? Or, does the ChromeDriver enter input into the first field and move on to the second field before we have focused the first field?

Or, another theory - we give the order to autofocus on view startup. The element focus() function is called. ChromeDriver fills out the first field, and moves onto the second field. The 'focus' event of the first field fires, and we try to update the selection back into the first field.

I'm amenable to 1. I'd rather fix the problem if we can.

I want to try changing the focus function to:

    focus: function (which) {
      try {
        var focusEl = this.$(which);
        // place the cursor at the end of the input when the
        // element is focused.
        focusEl.one('focus', function () {
          // focus was lost already. wah wah.
          if (! focusEl.is(':focus')) {
             return;
          }
          try {
            this.selectionStart = this.selectionEnd = this.value.length;
          } catch (e) {
            // This can blow up on password fields in Chrome. Drop the error on
            // the ground, for whatever reason, it still behaves as we expect.
          }
        });
        focusEl.get(0).focus();
      } catch (e) {
        // IE can blow up if the element is not visible.
      }
    },

The comment in the catch statement is interesting:

       // This can blow up on password fields in Chrome. Drop the error on
       // the ground, for whatever reason, it still behaves as we expect.

Maybe it doesn't behave as expected?

shane-tomlinson pushed a commit that referenced this issue Jul 29, 2014
…red before the refocus occurs.

Fixes Selenium/ChromeDriver where an attempt is made to autofocus an element
after ChromeDriver has already moved on to the next element.

The timing was:
1) A new view was rendered, an autofocus element found.
2) The autofocus element was focused, a timer set to check for focus 50ms later.
3) In that 50ms, ChromeDriver would fill out the field, and move on to the next field.
4) The timer expired, and the view tried to re-focus the autofocus element.
5) ChromeDriver failed the test.

fixes #1329 (on a mac)
@pdehaan pdehaan added the has PR label Aug 21, 2014
@vladikoff vladikoff removed the has PR label Sep 11, 2014
@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Sep 19, 2014

This is now happening sometimes in latest stable Firefox with Selenium 2.43.1 as well:

shane-tomlinson pushed a commit that referenced this issue Sep 19, 2014
…ed is hidden.

If the element is already visible, only attempt one focus.

fixes #1329
shane-tomlinson pushed a commit that referenced this issue Sep 19, 2014
…ed is hidden.

If the element is already visible, only attempt one focus.

fixes #1329
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.