"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'.
Autofocus attribute is working in tests as expected in any supported browser, including Chrome 79.
No warnings in JS console log.
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');
});
});
Cypress 3.8.2
Chrome 79.0.3945.117
Ubuntu 16.04 and 18.04
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.
Same here
Same issue. Developing an angular app and Chrome won't autofocus. Gives "_Autofocus processing was blocked because a document's URL has a fragment '#/login'._" error. Does work on Firefox.
Here's the tracking bug for chromium: https://crbug.com/1046357
I wouldnt say this is chrome related because I have same issue using firefox 72 beta. Element does not get auto-focused while running tests. After opening page in new tab I can see autofocus is working (same browser)
I noticed on cypress when open interface run tests and I start work with another screen and leave tests running ...
if there is no focus on chrome ... it don't pass tests with focus on fields.
I must to keep the focus on chrome window running
I wouldnt say this is chrome related because I have same issue using firefox 72 beta. Element does not get auto-focused while running tests. After opening page in new tab I can see autofocus is working (same browser)
@dcrystalj Safari doesn't has this issue.
Thanks,
Kenny.
Most helpful comment
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.