I'm completely new to Calabash, have spent the day learning (including getting all setup).
One thing i need some help with is how to find IDs with ease. So i have an Android app, which contains the placeholder text Username.
I've tried the following however its simply not working (I keep getting a timeout error that I presume is down to it not being able to find):
When I enter "some#user.com" as "Username"
So my questions:
1- is the above actually correct if i want to enter that email into a field with Username
2- If i didnt have a placeholder like above how can i easily obtain References or IDs and use that in
Then /^I enter "([^\"]*)" into input field number (\d+)$/
Many Thanks.
To find locators you should use the calabash console. If you run
calabash-android console your_app.apk
then once it starts
reinstall_apps
and then
start_test_server_in_background.
Once it's running you can use the calabash query syntax to find the elements you want to interact with - https://github.com/calabash/calabash-ios/wiki/05-Query-syntax.
To get you started query("*") will return everything that is currently on screen.
query("id:'UserNameField'") would only return the element with the id UserNameField.
To check if it's the one you actually want you can use flash("id:'UserNameField'") to make it flash a few times on your emulator/device.
Then to interact with it, I would advise not using the pre written steps. Make your own step definition and remember to require in the files you need to use calabash if you haven't already
require 'calabash-android/operations'
When /^I enter the username (.*)$/ do |username|
enter_text("id:'UserNameField'", username)
end
The prewritten steps can be useful but they end up making your scenarios hard to read, and once you do some more complicated things with it you will probably have to write your own steps anyway.
To help you decide the correct commands for your step definition it can be useful to run the commands, e.g. enter_text("id:'UserNameField'", 'username_you_want') in the calabash console so you don't have to run your tests everytime you add a line.
Related
I'm new to Espresso in Android Studio. The app I'm testing sends information to a REST service which creates and sends back an ID number. In another piece of the app I can request that ID number and get its information back. I want to store the ID returned when created and insert it into the requester to verify it is created. I've found some Espresso methods which can get a string from a view, but it warns that that is dangerous and likely not the best way to do that. how to get text from textview using espresso
Can someone explain the best way to accomplish this task if getting a string is not a good idea? Or, is that the only way to do it?
The question is if a instrumentation test is really what you want to do in your case. If something is testable in a easy way depends on your architecture. Large integration tests tend to break often as they hold many dependencies - consider to write unit tests first and https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html is also a good read regarding that topic.
I've implemented an ErrorHandler class into my app which is working just great but as I'm not sure if what I'm doing can fit into "best practices" just would like to share it with you to have your opinion.
My question is silly and my class is very simple. All that I do is the next: in every catch block of my whole java code I do a call to ErrorHabdler.log(e) (which works as an AsyncTask) and as I'm working with AWS what log(e) does is capture all information about the error, like message, device name and model, etc (NO user information) and sends a formatted email with the error to a specific email address.
Another possibility would be to create a new table into my AWS DynamoDB set called Exceptions and instead of sending an email in background write the error log into that new table to have errors more "centralized".
I'd like to know if you consider what I'm actualli doing a good practice, or if you prefer my second choice, or maybe none of them and you would better use a third party error logger.
Best!
There are several Crashlytics tools on the internet.
The best choice is to go to these tools, which make it easier to control crashes reports.
The most common, and is what I use in most of my projects, is Frabric.IO Crashlytics ,: https://fabric.io/kits/android/crashlytics
You can follow these steps to install Crashlytics in your project: https://fabric.io/kits/android/crashlytics/install
My program works like this:
1 - Make a copy of a public google spreadsheet to my drive account (the account of the user in the device), with the Drive Api, that works fine
2 - the public google spreadsheet has a apps script inside with a simple function, i need to execute that function.
3 - the function in the apps script is executed excelent (with the ID of the script), with the Apps script api from android.
the problem is: each time is performed the copy of the spreadsheet, the script inside changes the ID, i need a way to get that ID always.
How to solve this ?
Although this is an old post, hopefully this is useful for anyone looking:
var scriptID = ScriptApp.getScriptId();
Source: Google Apps Script Services API
I had a similar problem. I solved it by doing the following;
IN THE SHEET THAT IS BEING COPIED
add a function to the sheet's script with the following code: function ScriptID(){return ScriptApp.getScriptId()}
In some cell add the formula =ScriptID()
access the value of that cell to retrieve the script ID.
Now, when you copy the original, the function and the formula will be copied with it. In the new sheet, the result of the formula will show the script id for that sheet
WARNING: This may present some security issues since now your sheet's script ID is exposed to anyone with read access to your sheet.
Hope this helps
As of the date of this post, there is no built-in, programmatic way to get the ID of the Apps Script project file bound to a Sheets file.
If that changes in the future, please comment below to let me know.
An existing feature request to add this capability is at the link below. Please click the star in the upper left hand corner.
https://issuetracker.google.com/issues/111149037
In reference to the answer about getting the ID by putting a function in a Sheets cell, putting a function in a Sheets cell that calls a function name in a "gs" file requires that you open the bound script file and enter the function. So, if you are going to do that, you could just manually get the Apps Script project file ID.
There is also no way to use the Drive API to list Apps Script project files that are bound to a document. The Drive API won't find an Apps Script files that are not shown in Drive.
The Google Drive API won't find Apps Script files that are not visibly shown in your Google Drive. So, the Drive API can't be used to get any information either. And the Apps Script API won't list all Apps Script files in your account. It will only get files by ID. So, you can only get one Apps Script file and you need to know the file ID.
Hello I am beginner to Android development so I want to ask how to create dynamically changeable database (content) in Android?
I'm aware of sqlite shared preferences but how can I interact with them via internet and add new information like news apps? Could Parse help?
This is not a answer, but a comment rather, I don't have the 50 rep required to comment.
It all depends on the sort of functionality you want to achieve. I.e. do you want to be able to push new content to the device using the internet such as push notifications.
OR
Do you want the app to make a http connection to a api or your own news service on startup or on button press for example?
UPDATE
Ok you have decided you want something similar to option 2. I am not going to write code for you but I will point you in the right direction and if you get stuck, post a question.
Please take a look at:-
https://play.google.com/store/apps/details?id=com.rsoftware.news
If you have decided this is what you want or similar, this application uses an API calling infrastructure.
The API they use is called FAROO.
http://www.faroo.com/hp/api/api.html
I suggest reading the documentation, deciding if this is indeed what you want, then sign up and get a API key. Afterall it is free! enjoy coding, enjoy the errors that you will receive and persevere =).
How to make a API call
I suggest when using a API, test the queries through the browser first of all or use something like Runscope for testing their services. So first get their URL which is:-
http://www.faroo.com/api
If we were to go to this url we will get a 401 response code, which means unauthorised. This is because we haven't added our unique API key to the html query. So this url can take parameters. We simply append a ? to the end of the url and supply the parameters that FAROO offers such as:-
q which stands for query (what do you want FAROO to search for?)
start which is the number it should start from
length which is the number of results you want FAROO to return
key which is your unique to make the requests
etc etc...
So an example of a complete url would be:-
http://www.faroo.com/api?q=iphone&start=1&length=10&l=en&src=news&f=json
This url is for demonstration purposes... your own url will have a key=YourAPIKey
Also notice how the parameters are separated by & symbols i.e. q=iphone&start=1 so this part q we know stands for query which is iphone & start=1 & so on.
Hope this helps.
I'm creating an Android app, where I'd like to have a 'BUY 1 - send 1 to your friend' option.
I've been testing the idea of having a FREE limited version of my android app on the store and once a user has purchased the app they receive a FRIEND CODE that can be given to a chum to input into the FREE limited version, which ublocks the full version.
My concern is that 1 FRIEND CODE will be used multiple times - How do i make sure that after I've generated a friend code it can only be used once?
Any idea will be useful.
Why dont you create a list of used codes saved into your db table some where and check it if it already used. I would have suggested check for already generated but I am guess you probably have the code ready not to produce duplicate random friend codes.
Continuing Krishna's suggestion... When that code is used it is put up into the DB, and then whenever one attempts to use a code, that DB is checked to see if that code is already listed and thus already used.