question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"autofocus" not working with Chrome since Chrome 79

See original GitHub issue

Current behavior:

“autofocus” attribute works with Electron and with older Chrome versions, but it does not work in Chrome 79. When testing a page with “autofocus” attribute, cy.focused() returns no elements, and nothing is in focus.

Chrome console log:

Autofocus processing was blocked because a document's URL has a fragment '#/tests/__all'.

Desired behavior:

Autofocus attribute is working in tests as expected in any supported browser, including Chrome 79. No warnings in JS console log.

Test code to reproduce

Simple HTML page:

<!DOCTYPE html>
<html>
<body>
<form>
  First name:<br>
  <input type="text" name="firstname" autofocus>
  <br>
  Last name:<br>
  <input type="text" name="lastname">
</form>
</body>
</html>

Code of the integration test:

describe('Focus', function() {
    it.only('autofocus', function() {
        cy.visit('./af.html');
        cy.focused().should('have.attr', 'name','firstname');
    });
});

Versions

Cypress 3.8.2 Chrome 79.0.3945.117 Ubuntu 16.04 and 18.04

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
jennifer-shehanecommented, Jan 21, 2020

Welp, that is very weird. Confirmed this happens in Chrome 79. Did not narrow down to what specific release.

Screen Shot 2020-01-21 at 10 59 08 PM
5reactions
jackylcommented, Feb 3, 2020

Hi,

I think it’s broken when there’s hashtag in the url, in my case there were 4, and the console message was:

Autofocus processing was blocked because a document's URL has a fragment '####'.

If you open the simple html page in chrome without any testing integrated, autofocus works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

autofocus="true" is not working in google chrome when ...
All forms are loaded in an iframe and focus is set on the first field of the form using autofocus="true" . But after...
Read more >
autofocus does not work when URL contains fragment in ...
Issue 1046357 : autofocus does not work when URL contains fragment in Chrome 79 ; Status: Assigned (was: Unconfirmed) ; Owner: tkent@chromium.org
Read more >
Autofocus not working with new Chrome 79? - Is this a bug?
After updating Chrome to 79 it looks like autofocus option for select2 stop working for me. Working for previous version, other browsers no ......
Read more >
Cross Browser Compatibility of Autofocus attribute in Chrome 79
Autofocus attribute is Fully Supported on Chrome 79. Checkout overall cross browser compatibility of Autofocus attribute on Chrome 79.
Read more >
autofocus - HTML: HyperText Markup Language | MDN
The autofocus global attribute is a Boolean attribute indicating that an element should be focused on page load, or when the <dialog> that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found