Changing device orientation to landscape during the test execution is not working as expected

31 views
Skip to first unread message

Rama

unread,
Jul 21, 2016, 9:42:26 AM7/21/16
to calabash-android
Hi

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?

Here is my scenario log:
---------------------
@landscape @tablet
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

output:

 Scenario: Catch Up content matches API in landscape                  # features/landscape.feature:30

["@landscape", "@tablet"]

"Device orientation not set to Landscape"

-----------------------

life-cycle-hooks.rb
*********************
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
    feat_name = scenario.name
    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



Gemfile.lock

Rama

unread,
Jul 22, 2016, 4:15:36 AM7/22/16
to calabash-android
 And also I am using Ruby 2.3.0, earlier tried with Ruby 2.1.2 as well.   Am not sure is this issue from adb-extension version, when i tried from ruby console it was working fine, but experiencing issues during the test execution

tobias....@xamarin.com

unread,
Jul 22, 2016, 11:49:14 AM7/22/16
to calabash-android
You have already made on thread on this in this google groups, and the maintainer of the 3rd party (to Calabash) gem you are using wrote a reply.

This google groups is dedicated to Calabash usage. The discussion about 3rd party gems should not go here.
Reply all
Reply to author
Forward
0 new messages