"autofocus" not working with Chrome since Chrome 79
See original GitHub issueCurrent 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:
- Created 4 years ago
- Reactions:3
- Comments:12 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Welp, that is very weird. Confirmed this happens in Chrome 79. Did not narrow down to what specific release.
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.