5 ms·
Hey, looks nice. Wonder how lib is detecting inputs by "user-visible labels". Looks by html structure, or uses some "magic" methods?
by lfx 13y ago
Hey, looks nice.
Wonder how lib is detecting inputs by "user-visible labels". Looks by html structure, or uses some "magic" methods?
- mherrmann 13y agoThanks! For now, it looks by (x, y) position on the web page.
- hpaavola 13y agoPosition of what? Why? Given following markup: <label for="foobar">Lorem ipsum</label> <input id="foobar"> Does write('omg', 'Lorem ipsum') write into #foobar? Just to clarify since position of those two elements might not be similar at all.
- mherrmann 13y agoIn that case, it will write into #foobar because it is smart enough to understand that <input/>s can be written to, and not labels. It works in a way that is very similar to us humans: If someone tells us to "write 'Michael' into the 'First Name' field", we look for the text "First Name" and then to the right and bottom of this text if there is a field that can be written to. So, position in this case is position on the page in (x, y) coordinates. If there are multiple occurrences (eg. two "First Name" fields) then Helium scans the page top-to-bottom, and closest to the element you last interacted with. Like a human would normally also do.