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

:host strategy cannot type strings with single quotes, but :preferences strategy can. #616

Closed
jmoody opened this issue Nov 19, 2014 · 5 comments
Assignees
Labels

Comments

@jmoody
Copy link
Contributor

jmoody commented Nov 19, 2014

Related to Timeout when typing char that does not exist #605

Workaround

There is no satisfactory workaround. User's will encounter this problem when running tests against iOS 8 devices or when using the non-default :host strategy.


# :host - works
> keyboard_enter_text "wasn\\'t"
> keyboard_enter_text(escape_quotes("wasn't"))

# :preferences - results in an infinite loop
> keyboard_enter_text "wasn\\'t"
> keyboard_enter_text(escape_quotes("wasn't"))

In the short term, this kind of patch will work for most users.

string = "wasn't"
if ios8? and not simulator?
  text_to_type = escape_quotes(string)
else
  text_to_type = string
end
keyboard_enter_text text_to_type

Xcode 6.0.1, Xcode 6.1, Xcode 6.1.1

Using the develop branches of the toolchain: calabash-cucumber, run-loop, and calabash-ios-server.

Any iOS, simulator or device.

Reproduce

1. Launch an app with a text field from the console.
> start_test_server_in_background({:uia_strategy => :host})
2. Type a string with a single quote.
> keyboard_enter_text "Single ' in a string"

Expected

The string to be typed as "Single ' in a string".

Found

> keyboard_enter_text "Single \' in a string"
Sending UIA command
uia.typeString('Single \' in a string', '')
RuntimeError: uia action failed because: 
SyntaxError: Unexpected identifier 'string'. Expected ')' to end a argument list. 
eval@[native code]

Notes

String Strategy Result
wasn't :host Unexpected identifier 't'. Expected ')'
wasn't :preferences "wasn't"
wasn\'t :host Unexpected identifier 't'. Expected ')'
wasn\'t :preferences "wasn't"
wasn\\'t :host "wasn't"
wasn\\'t :preferences Timeout when typing char that does not exist #605

There is this documentation on the wiki [1] that recommends using escape_quotes [2]. That documentation was written before the :preferences route existed.

The escape_quotes is broken for the :preferences strategy; I will create a new issue for this.

@jmoody
Copy link
Contributor Author

jmoody commented Nov 19, 2014

@john7doe @rasmuskl

This might be of interest to you since UITest uses the :host JavaScript.

@krukow
Copy link
Contributor

krukow commented Nov 28, 2014

With this pull request to run loop, calabash/run_loop#82, we get the following behavior (Note: tested on simulators so far, but devices shouldn't be different).

Ruby String UIA Strategy String entered on iOS keyboard
"karl's problem" :host karl's problem
"karl's problem" :preferences karl's problem
"karl's problem" :shared_element karl's problem
"karl's "problem"" :host karl's "problem"
"karl's "problem"" :preferences karl's "problem"
"karl's "problem"" :shared_element karl's "problem" ***
"karl's \ problem" :host karl's \ problem
"karl's \ problem" :preferences karl's \ problem
"karl's \ problem" :shared_element karl's \ problem

*** UPDATED @jmoody + @john7doe "karl's problem" ==> "karl's "problem""

@krukow
Copy link
Contributor

krukow commented Nov 28, 2014

To me this is the most natural behavior

@krukow
Copy link
Contributor

krukow commented Nov 28, 2014

There is a new method used under the hood: escape_string (composing escape_quotes and escape_backslashes)

@krukow krukow mentioned this issue Nov 28, 2014
@krukow
Copy link
Contributor

krukow commented Nov 29, 2014

Should be fixed in 0.11.5.pre3 - #630

Please reopen if you see fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants