I was looking into this issue and was fascinated following results, AHK considers both vars x := 5 and y := "6" numbers but cjson somehow knows which is string and which one is number,Xeo786 wrote: ↑15 Jun 2022, 02:04Yes, it can be fixed using by adding one line, I will try to fix this issue in the next update,ahk7 wrote: ↑14 Jun 2022, 12:28OK I didn't realise, but is that common practice that you have to convert numbers to strings using webdriver?
If I use years:="2022" it does it indeed work as expected (hence the "hello" does too of course).
Shouldn't Rufaydium convert numbers to strings for the .value .sendkey options? That is what I expected and perhaps others too.
If not, it should probably be added to the documentation?
Edit: or much shorterhttps://github.com/Xeo786/Rufaydium-Webdriver/blob/main/README.md?plain=1#L579 wrote: ;setting value
Element.value := "somevalue"
; Note: when sending a number or variable representing a number, convert it to a string first:
; Element.value := "2022" and not Element.value := 2022
; or
; year := "2022" ; not year := 2022
; Element.value := year
; same goes for .SendKey("2022") and .SendKey(year)
; Alternative prepend variables with a "" to convert it to a string:
; year := 2022
; .value("" year)
; .SendKey("" year)
All data sent to form elements are required to be strings.
Code: Select all
x := {"value":5}, y := {"value":"6"}
msgbox, % "<" x.value "><" y.value ">`n X isnumber:" Isnumber(x.value) "`n y isnumber:" Isnumber(y.value)
msgbox % x := json.dump(x) "`n" y := json.dump(y)
x := json.load(x), y := json.load(y),
msgbox, % "<" x.value "><" y.value ">`n X isnumber:" Isnumber(x.value) "`n y isnumber:" Isnumber(y.value)
msgbox % x := json.dump(x) "`n" y := json.dump(y)
return
Isnumber(var){
if var is number
return 1
}