taiko
taiko copied to clipboard
Ability of supporting xpath as a parameter to checkBox
click($("/html/body/input[0]"))
works, but checkBox($("/html/body/input[0]")).check()
doesn't.
checkBox($("/html/body/input[0]")).check()
throws an error 'Uncaught You are passing a ElementWrapper
to a checkBox
selector. Refer https://docs.taiko.dev/api/checkbox/ for the correct parameter'
Currently, checkBox extends elementWrapper
.
And, it's necessary that elementWrapper
needs attrValuePairs
(one of its fields) to not be an instance of elementWrapper.
And, currently, when an xpath
is passed as a selector for checkBox, attrValuePairs
is a dollarWrapper
, which makes attrValuePairs
an instance of elementWrapper
which is currently not acceptable as a field to elementWrapper
.
A potential solution: Add another field to pass as a constructor to checkBoxWrapper
, dollarSelector
which gets conditionally populated when the parameter is an xpath, and attrValuePairs
is conditionally set to null
when the parameter is an xpath . Now, deal with the dollarSelector
inside the checkBox
constructor itself.
Alternatives considered:
Having elementWrapper
deal with this conditionally. Didn't do so, because it would be affecting a lot of other wrappers which extend elementWrapper
. And, making changes only in checkBoxWrapper
felt sufficient.
Just realised there's already an issue opened. https://github.com/getgauge/taiko/issues/1519 (my bad, I should have searched it before!)
A note that I'd like to work on this. I'm unable to assign this to myself.
Sure, I can assign it to you. Just to clarify this won't break existing behaviour right? (i.e it should accept attribute value pairs too)
Just to clarify this won't break existing behaviour right? (i.e it should accept attribute value pairs too).
I doesn't seem to break. I tested it locally. And, it passes the already written tests (which considers attribute value pairs) too.