As previously stated, you used waits to allow time for focus to be brought back to the window with tv_title_submit resource-id. At this point, I would start dumping page source every few seconds to verify the resource-id is not visible. Here's some code we use to accomplish the search:
require 'nokogiri'
# Grab screen elements to determine if any of the named element exist
#
# field can be any type of field stored on the Android page in XML
#
# Example: elements_exist? 'resource-id', ['com.android.vending:id/uninstall_button',
# 'com.android.vending:id/launch_button']
#
# Note: The raw form of the field is used, i.e. with hyphens.
# Note: 'values' can be an array of regular expressions and/or strings
def elements_exist?(field, values)
values = [values] unless values.class == Array
# The display might not be ready to provide the page source
wait = Selenium::WebDriver::Wait.new(timeout: 3)
wait.until do
begin
@source = appium_driver.get_source
true
rescue Selenium::WebDriver::Error::UnknownError
log.debug "Can't obtain page source, try again"
false
end
end
doc = Nokogiri::XML(@source)
values.each do |value|
return true if doc.to_s =~ /#{field}=\"#{value}\"/
end
false
end