performAction('enter_text_by_selector',"#{elem
ent}", text)
end
end
!
#features/ios-support/ios_base_page.rb
!
module BasePageOperations
include Calabash::Cucumber::Operations
def enter_text(text, element)
touch("webView css:'#{element}'")
keyboard_enter_text(text)
end
end
!
Having defined the platform specific methods in appropriate
places, we need to load them conditionally for each
platform.
We can do that by simply requiring the appropriate folders
in run time for different platforms in 'cucumber.yml' file as
given:
#config/cucumber.yml
!
android: PLATFORM=android -r features/
android-support -r features/pages -r
features/step_definitions
ios: PLATFORM=ios -r features/ios-support
-r features/pages -r features/
step_definitions
!
Step 5: Running the tests across platforms:
Done. We’ve built our first test, now we want to see it
running.
33
To run on Android:
>calabash-android run <apk-path> -p
android
!
To run on ios:
>cucumber -p ios
Scalability to new platforms:
Hybrid apps have two advantages over native apps
from a test automation perspective. Hybrid apps have
the same HTML elements on all platforms and most of
the times, they have the same navigation steps across
the app. This gives us the benefit of abstracting the
platform specific code to the last layer instead of
replicating the steps and pages for each platform.
!
continued ...
STAY IN TOUCH
Sign up for our Perspectives Newsletter.
!
We’ll periodically send you a newsletter filled with great
educational resources, thought leadership and event
information.
Share this ebook.
Sign Me Up