I am using calabash-android 0.8.0 (also happening on 0.7.3), android-dab-0.0.6, android-dab-extension-0.1.1. I am using hooks to set the device orientation before each scenario and the device is manually set to Portrait mode. My regression pack starts with portrait mode and after couple of features need to set to landscape and then to portrait mode.
But when I need to set to landscape, its not recognising and hence the tests are failing as there are certain elements need to be verified in landscape mode.
I have attached my gem lock file and also given the before and after hooks. When I set my device to landscape manually then the tests are fine, but changing device orientation with hooks is not, can some one please help as My regression pack is a combination of portrait and landscape. Is it possible to set the device orientation irrespective of the physical orientation?
Scenario: Catch Up content matches API in landscape
When I navigate to the Entertainment sub section Highlights screen
And I select Catch Up tab from Entertainment Highlights section
Then I see Catch Up content matches API
Scenario: Catch Up content matches API in landscape # features/landscape.feature:30
["@landscape", "@tablet"]
"Device orientation not set to Landscape"
require 'calabash-android/management/adb'
require 'calabash-android/operations'
require 'android-adb-extension'
require 'calabash-android/management/app_installation'
Before do |scenario|
p scenario.source_tag_names
if scenario.source_tag_names.include? "@reinstall"
uninstall_apps
install_app(ENV["TEST_APP_PATH"])
install_app(ENV["APP_PATH"])
end
start_serv
sleep 1
(scenario.source_tag_names.include? "@landscape") ? set_device_to_landscape : set_device_to_portrait
if scenario.source_tag_names.include? "@require_login_page"
ActionBarHelper.dismiss_cc_on_boarding_screen
sleep 2
ActionBarHelper.goto_my_account_screen
on LoginPage do |page|
page.touch_sign_out_button
end
end
end
def start_serv
start_test_server_in_background
end
After do |scenario|
if scenario.failed?
screenshot_embed
nam = Time.new
scnr_line = scenario.line.to_s
run_adb_command("logcat -v time 2>&1 -d > '#{scnr_line}_#{nam}_#{feat_name}_log.txt'")
end
screenshot_embed
shutdown_test_server
clean_older_testservers(5)
end
def run_adb_command(cmd)
full_cmd = "#{default_device.adb_command} #{cmd}"
raise "failed to run #{full_cmd}" unless system(full_cmd)
end
def set_device_to_portrait
ADB.set_portrait
sleep 5
(ADB.portrait?) ? (ENV['DEVICE_ORIENTATION'] = 'portrait') : (p "not set to portrait")
end
def set_device_to_landscape
ADB.set_landscape
sleep 5
(ADB.landscape?) ? (ENV['DEVICE_ORIENTATION'] = 'landscape') : (p "Device orientation not set to Landscape")
end