I need to automate a test on an IOS app using UI automation.
I need to test the following scenario.
1) open the mail app and select a file to share. This will open my app
2) Now I need to perform UI actions on my app and do some tests
I can't figure out how do automate this scenario using Instruments or Appium. All these tools take bundle name of one app. I need a way to control and perform UI actions on two app from a single script.
Any suggestions?
Edit: For clarification
This is not possible within one session
The solution is to split up your tests to encompass one or more webdriver sessions.
Part One:
desired_caps['app'] = 'sampleApp1'
driver = webdriver.new('http://0.0.0.0/wd/hub:4732', desired_caps)
// Do what you need to do.
driver.quit()
Part Two:
desired_caps['app'] = 'sampleApp2'
driver = webdriver.new('http://0.0.0.0/wd/hub:4732', desired_caps)
// Do what you need to do.
driver.quit()
Related
I am required to create iOS unit tests, where i need to push an sql .db into app location/sandbox/whatever (may be from testsuit's setUp() func) and run some CRUD operations from the testcases and later delete the db from tearDown() when tests done. How can i push a .db into app location for test, which will be used just like a db used inside app.
Another question, I need to run automated tests, so is there any command (like in Android we use adb, in Tize we use gdb) for iOS app to insert these database file in app location to run those testcases. If i am missing any point please help.
What is the standard way to test CRUD operations in a simulated db for iOS.
As far as my study, there is no adb/sdb like tool for iOS. Moreover there is an workaround for performing test on real database.
Steps
Keep the test-database into App/resource folder. You can skip this large test-database from your release build by following these technique.
Make a function in App side to replaceWithTestDatabase(), which basically replace your App database with App/resource/test-database. You can temporary copy current App db if you need.
If you want to access from AppTests (unit test), you can simply call Aapp/replaceWithTestDatabase as iOS Tests are hosted under main App.
If you want to access from AppUITests, you need to send extra launch argument from setUp() method to let App know that it should call replaceWithTestDatabase from app delegates. Here is a nice explanation how we can send arguments to main App from AppUITests.
Hope it helps.
Currently I'm writing all the Test Case actions in one javascript file, and using Xcode Instruments automation.traceTemplate file for executing the Test Case.
Following are contents from TestCase file.
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();
//target.logElementTree();
target.delay(2);
UIATarget.localTarget().captureScreenWithName("Application launched");
target.frontMostApp().mainWindow().textFields()[0].setValue("demo");
target.delay(2);
UIATarget.localTarget().captureScreenWithName("Username entered");
var passwordfield = target.frontMostApp().mainWindow().secureTextFields()[0];
passwordfield.setValue("demo");
My Requirement:
I want to perform one action at a time on iOS device using Xcode Instruments instead of passing complete Test Case file as a input similar to implementation of Appium tool.
Thanks in advance..........
XCode instruments natively do not support on the fly Javascript. You have to have all your javascript in one file and execute all of the script at once. You are not able to stop execution, have separate test cases etc.
This is where appium comes into play, it will allow arbitrary JS execution. You create your test cases in the appium/selenium format and they would send commands to instruments in the background.
Run through this tutorial http://appium.io/slate/en/tutorial/ios.html?java#native-ios-automation and you don't even have to use JS, you can use Java/Ruby and you will be in a better shape.
Check out appiumRepl
You can send commands one-by-one and watch them happen on the device/emulator in realtime :)
There's a Ruby REPL as well.
I writing JavaScript test for my iOS app. I am hoping of using Apples Profiler and UIAutomation.
1) I was wondering how can I reset the app every time I run the test. I would like to reset my app to a consistent state every time before I run a new test. Have separated my tests into few groups. Every test of the first group should start on the first screen containing a tableView and filters for sorting elements in that table should be set to a consistent state. Second group of tests should start on the Settings screen and some options/switches should be pressed in particular order for me to test the UI.
2) Also first time the app starts there is a tutorial. How can I make the app think it is freshly installed and test the tutorial feature.
Thanks for the answers
How can I make the app think it is freshly installed ?
As the iOS applications are sandboxed, the only way is to delete and re-install the app every time.
In the Illuminator framework that I wrote (which extends UIAutomation), we provide an automation bridge that allows us to send "reset" commands to the app, putting it into a known state before each test is run. This makes the testing very repeatable, even if some tests fail.
Additionally, the command line scripts can recover the test run even if the app crashes.
I've got an ISettings interface which is implemented in a platform-specific manner on Mono For Android and iOS. For Mono For Android, I'm using Activity.GetSharedPreferences to implement my settings - and this works fine from my application.
However, I want to be able to test this with NunitLite (which I'm using successfully to test my other core code).
The problem is that for my test fixture, I need an Activity on which to call GetSharedPreferences. Is there a way of accessing the currently running Activity either generically or via the NunitLite implementation?
James
You can access Shared preferences via:
Application.Context.GetSharedPreferences("whatever", FileCreationMode.Private)
You don't need an activity.
I'm developing a card-game in Ruby on Rails, and trying to work out how best to test it.
When a player joins a game, their Player object is stored in the session. Obviously, in order for the game to work, I need more than one Player in a game at once. Since sessions are the same for different tabs in one browser, I'm currently testing a 2-player game by having the app open in FireFox and Internet Explorer at the same time.
Before I go off and download Chrome in order to test a third player... is there an easier way of doing this?
Edit: To clarify, I'm not yet at the stage where I want to run automated tests to see if it breaks. I'm at the stage where I want to be able to hack the back-end db, then refresh the page and see how it looks now, or click a button to see the (usually) failure response, or whether the behaviour is looking right.
You can run Firefox with multiple profiles. From a command line go to the directory Firefox is installed in and run firefox -P. Create a profile for every instance that you want to run. Close the profile manager, then for each profile run firefox -no-remote -P "profile name". You can run as many instances of Firefox as you want, and each one runs with an independent profile and thus independent session.
Automate it!
You really don't want to be manually testing this. You could use a Ruby script with the curl libs to generate the 'moves' and manage the response including the session cookie.
As a teaser, see this snippet from the API docs, sounds like it would help you..
easy.cookiejar = "cookiejar.file" => "pwd string"
Set a cookiejar file to use for this Curl::Easy instance.
This file will be used to persist cookies.
Use http://watir.com/ to create ruby scripts exercising your game.
Use multiple Watir::Browser instances to run multiple browsers.
Use firefox' profiles and -no-remote switch to keep them separated. See also this question.
Rather than opening a new tab, create a new window in your Web browser. The new window will have its own session. This works for Internet Explorer, but not for Firefox. I haven't tested it in the WebKit based browsers.