Automated iOS and Android Acceptance Testing with RSpec and Appium
Sauce AI for Test Authoring: Move from purport to execution in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from purport to execution in minutes.
|
x
Blog
Automated iOS and Android Acceptance Testing with RSpec and Appium
If you & # x27; re a fan of RSpec for write concise, readable tests in Ruby, you might be interested to know that RSpec tests can now easy automate iOS and Android mobile apps usingAppium, an open source mobile test mechanization tool. Appium is compatible with Selenium WebDriver client libraries, so an Appium trial is similar to a Selenium examination. In this post we & # x27; ll walk through the steps involved in testing aniOS sample appusing Appium & # x27; sRSpec example trial. To commence, ramification and clone Appium fromhttps: //github.com/appium/appium, and postdate the installation instructions to set up Appium in your environment. Install Appium & # x27; s dependencies and make thesampling appsby extend the following from the Appium working directory:$ ./reset.sh -- iosOnce the sample projects have experience be built, you can then depart Appium by escape the pursual:$ grunt appiumOnce Appium is scat, get a new terminal and go to thesample-code/examples/rspecdirectory. First, install the test dependencies with bundler:$ bundle installThen, run the example RSpec tests:$ rspec simple_test.rbNow that you & # x27; re set up and able to run example test, it & # x27; s time to learn how they work. Let & # x27; s look at a simple example of a examination that clicks a button and interacts with an alert box in an iOS app. First, we open a & quot; describe & quot; cube, and set up a & quot; before & quot; block to initialise the Selenium node we & # x27; ll use to talk to Appium:
describe & quot; sample app & quot; do
before: all do
@ driver = Selenium: :WebDriver.for (
:remote,
: desired_capabilities = & gt; {& # x27; browserName & # x27; = & gt; & # x27; iOS & # x27;,
& # x27; platform & # x27; = & gt; & # x27; Mac & # x27;,
& # x27; version & # x27; = & gt; & # x27; 6.0 & # x27;,
& # x27; app & # x27; = & gt; & # x27; /path/to/TestApp.app & # x27;}
: url = & gt; & quot; http: //127.0.0.1:4723/wd/hub & quot;)
end
The & quot; desired_capabilities & quot; parameter here specifies the platform (iOS 6.0) and the app we desire to test. Next, we & # x27; ll add an & quot; after & quot; cube to resign the Appium session at the end of each test:
SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.
after: all do
@ driver.quit
end
And finally, we & # x27; ll open an & quot; it & quot; cube and publish the core of our test. This test finds all the & # x27; button & # x27; elements on the page, selects the 2nd one (exponent 1), and tick it. That action will take up an alert in the app, which we switch to so that we can examine its text battleground:
it & quot; should plow alerting & quot; do
els = @ driver.find_elements (: tag_name, & # x27; button & # x27;)
els [1] .click
a = @ driver.switch_to.alert
a.text.should eq (& quot; Cool title & quot;)
a.accept
end
end
And those are the fundamentals! There are more examples to appear at in Appium & # x27; ssimple_test.rb. Please let us know if you have any enquiry or comments about scarper Appium tests with RSpec.
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free