Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix set value immediately, replace value #484

Merged
merged 4 commits into from
Aug 15, 2019

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Aug 14, 2019

Below error happens for set immediate value and replace value.

Selenium::WebDriver::Error::InvalidArgumentError:         Selenium::WebDriver::Error::InvalidArgumentError: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 11 path $.value
            io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 11 path $.value
            	at io.appium.espressoserver.lib.http.Router.route(Router.kt:203)
            	at io.appium.espressoserver.lib.http.Server.serve(Server.kt:49)
            	at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
            	at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
            	at java.lang.Thread.run(Thread.java:764)

Tested in Ruby to make the behaviour the same as UIA2


https://dev.azure.com/kazucocoa/ruby_lib_core/_build/results?buildId=1265

@KazuCocoa KazuCocoa changed the title Km/fix set value replace value fix set value replace value Aug 14, 2019
@@ -1,5 +1,5 @@
package io.appium.espressoserver.lib.model

data class ElementValueParams(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w3c also requires text parameter to be set, which contains a string rather than array

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

val viewInteraction = Element.getViewInteractionById(elementId)
if (isReplacing) {
viewInteraction.perform(replaceText(value))
} else {
viewInteraction.perform(typeText(value))
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this block of code duplicated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A part of.
Will refactor as another PR (SendKeys.kt)

Pair(first=true, second=false) -> params.text!!
else -> params.value!!.joinToString() // for backward-compatibility
Pair(first=false, second=true) -> params.value!!.joinToString(separator="") // for MJSONWP
else -> params.text!! // Prior W3C
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, text was added in W3C

@KazuCocoa KazuCocoa changed the title fix set value replace value fix set value immediately, replace value Aug 15, 2019
@KazuCocoa KazuCocoa merged commit c351b8d into appium:master Aug 15, 2019
@KazuCocoa KazuCocoa deleted the km/fix-set-value-replace-value branch August 15, 2019 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants