I have a form that is dynamically created based on a configuration file that I have. I am now trying to test that form with Calabash on IOS. When I enter a first name, Calabash is unable to find the last name field. Even though I tap the return key. I've also tried waiting for keyboard to disappear and also added a 10 second sleep in my code. Here is the UI instead after first name the next element it sees is address:
Here is my code:
Given(/^I create a customer$/) do
touch("* id:'Header Create Button'")
wait_for_none_animating()
time = 40
time_start = Time.now
begin
time_running = Time.now - time_start
elementsFoundArray = enterFieldData(elementsFoundArray)
break if elementsFoundArray.count == createFields.count
swipe :up
wait_for_none_animating()
sleep 2
puts "#{elementsFoundArray} -- size #{elementsFoundArray.count}"
end until (time_running.to_i >= time)
end
and here is the method the above code calls:
def enterFieldData(elementsFoundArray)
numberOfCreateCellsVisible = query("UITableViewCell").count
puts "number of cells is #{numberOfCreateCellsVisible}"
for index in 0...numberOfCreateCellsVisible
cellLabels = query("UITableViewCell index:#{index} descendant label",:text)
puts "#{cellLabels} :)"
if cellLabels.include? "Title"
if !elementsFoundArray.include? "Title"
titleOptions = query("UITableViewCell index:#{index} descendant button")
randomTitle = rand(0...titleOptions.count)
touch("UITableViewCell index:#{index} descendant button index:#{randomTitle}")
elementsFoundArray << "Title"
end
end
if cellLabels.include? "First Name"
if !elementsFoundArray.include? "First Name"
possibleFirstNameValues = Array(ConfigRead.getConfigData("generic_data","FirstName",nil))
randomIndex = rand(0...possibleFirstNameValues.count)
randomFirstName = possibleFirstNameValues[randomIndex]
touch("UITableViewCell index:#{index}")
keyboard_enter_text("#{randomFirstName}")
keyboard_enter_char('Return')
if keyboard_visible?
wait_for_no_keyboard()
end
# just to make sure keyboard isnt blocking
sleep 10
elementsFoundArray << "First Name"
end
end
if cellLabels.include? "Last Name"
if !elementsFoundArray.include? "Last Name"
possibleLastNameValues = ConfigRead.getConfigData("generic_data","LastName",nil)
randomIndex = rand(0...possibleLastNameValues.count)
randomLastName = possibleLastNameValues[randomIndex]
touch("UITableViewCell index:#{index}")
wait_for_keyboard()
keyboard_enter_text("#{randomLastName}")
keyboard_enter_char('Return')
wait_for_none_animating()
elementsFoundArray << "Last Name"
end
end
end
return elementsFoundArray
end
But the if statement for last name doesnt get executed. If I comment out the first name if statement then the last name field gets filled, if both fields are not commented then only the first name gets filled.
I dont know if im doing something wrong or its a bug with calabash.
I have a form that is dynamically created based on a configuration file that I have. I am now trying to test that form with Calabash on IOS. When I enter a first name, Calabash is unable to find the last name field. Even though I tap the return key. I've also tried waiting for keyboard to disappear and also added a 10 second sleep in my code. Here is the UI instead after first name the next element it sees is address:
Here is my code:
and here is the method the above code calls:
But the if statement for last name doesnt get executed. If I comment out the first name if statement then the last name field gets filled, if both fields are not commented then only the first name gets filled.
I dont know if im doing something wrong or its a bug with calabash.
Any help appreciated thanks