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.

Cannot get element via name

See original GitHub issue

I have an array of input elements, for inputting an address.

I am trying to get the first input, to type in an address.

cy.get('[name=street[0]]').type('123 Townsville'); // doesn't work
cy.get('[name=street[]]').type('123 Townsville'); // doesn't work
cy.get('[name=street]').type('123 Townsville'); // doesn't work

Before anyone mentions using a data attribute, or adding a class etc - I am dealing with the markup with out-of-the-box Magento and I am not interested in changing it just to pass the tests. It should work using the test I have written.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jennifer-shehanecommented, Mar 25, 2019

cy.get('[name="street[0]"]') works for me against the following html: <input type="text" name="street[0]">, can you verify that this is the html that is rendered to the page?

0reactions
ghostcommented, Mar 25, 2019

Including the double-quotes was the key.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript can't find element by id? [duplicate] - Stack Overflow
The problem is that you are trying to access the element before it exists. You need to wait for the page to be...
Read more >
Document.getElementById() - Web APIs | MDN
The Document method getElementById() returns an Element object representing the element whose id property matches the specified string.
Read more >
HTML DOM Document getElementsByName() - W3Schools
Definition and Usage. The getElementsByName() method returns a collection of elements with a specified name. The getElementsByName() method returns a live ...
Read more >
Searching: getElement*, querySelector*
If an element has the id attribute, we can get the element using the method document.getElementById(id) , no matter where it is.
Read more >
Issue with jQuery (Can't find element in DOM by ID) - Laracasts
data('away-name'); $(this).find("#awayTeamLabel").text(awayTeamName); });. It works in one file of my code but not in another ...
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