facebook Skype Linkedin
Skip to content
Home » Quality Assurance » Clear field with calabash-ios

Clear field with calabash-ios

Recently while automating one of applications with calabash-ios we (QA team of Scimus) faced a problem with clearing a field with a certain text. When we would use one of out of box method

[code lang="ruby"]I clear (?:input|text) field number (\d+)[/code]

it would work for the first time but then would start failing. As field was cleared, but iOS remembers a previous state and puts the same value back with autoselected. So technically this steps works fine, it clears a field but then puts it back and our test for edit field did not work as expected.
This is a soltion that we implemented in order to fix this problem.

[code lang="ruby"]
Then /^I clear a field with "([^\"]*)" text$/ do |name|
name = set_value name
element = query("UITextFieldLabel text: '#{name}'")[0]
touch(element)
wait_for_keyboard
name.to_s.split('').each do |c|
keyboard_enter_char 'Delete'
end
end
[/code]

It is just pretty simple solution, you tap to erase a number of character in a field times and field becomes empty. Works every time and test is stable now. I hope it will help someone out there.

Master field clearing with Calabash to conquer iOS app testing challenges and streamline your development process. Visit our website for more insights, expert tutorials, cutting-edge solutions, and guides. Scimus is your partner in navigating the complex landscape of software development and testing.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our Newsletter