I need to get the value of an <input>
, specifically the stuff that is held inside its value attribute.
However, the input
is not visible, so that seems to be a problem for testcafé.
Does anyone know how to work around that? Is there a special option you can use with the Selectors
to make it work?
Thanks for helping me out, I appreciate any help!
I need to get the value of an <input>
, specifically the stuff that is held inside its value attribute.
However, the input
is not visible, so that seems to be a problem for testcafé.
Does anyone know how to work around that? Is there a special option you can use with the Selectors
to make it work?
Thanks for helping me out, I appreciate any help!
Share Improve this question edited Jul 16, 2019 at 14:55 Alex Skorkin 4,2743 gold badges27 silver badges48 bronze badges asked Sep 10, 2017 at 18:14 fweidemann14fweidemann14 1,9933 gold badges14 silver badges21 bronze badges2 Answers
Reset to default 7Got it, simply declare a Selector like this let yourInputs = Selector('input[type="hidden"]')
, this will get all hidden inputs
and return a NodeList which you can iterate over in your test.
If you want to be more specific and select over an ID or name, do it like @lumio.
Then you can access the value in your test run with an await yourInputs.value
.
I guess you mean a hidden input element as in <input type="hidden" />
and you want to receive the value before you're sending it to your Node application. You can use querySelector
for this.
console.log( document.querySelector( 'input[name=test]' ).value );
<input type="hidden" name="test" value="hello world" />
For TestCafé you got the Selector
-constructor which creates a selector.
As fweidemann14 pointed out, you can do the following:
const hiddenInputs = Selector( 'input[type="hidden"]' );