I recently started writing a detail automated test script on MonkeyTalk for my application. I am fascinated with the power of this tool, but there is a small issue i am facing.
I am writing a data driven test case using csv file which is running file. But now I want to induct some verification on view, I believe that could be done using javascript but I couldn't be able to work it around. Can anyone show me how.
Here is what i am doing :
1) my script file to run the data driven test case for csv file
Script DataDrivenLogin.mt RunWith login.csv
2) my other script file where i am using the views
load("libs/MyApp.js");
MyApp.DataDrivenLogin.prototype.run = function(email, _password) {
/**
* #type MT.Application
*/
var app = this.app;
email = (email != undefined && email != "*" ? email : "<email>");
_password = (_password != undefined && _password != "*" ? _password : "<_password>");
app.image("email").tap();
app.input("Email Address").tap({timeout:"2000"});
app.input("Email Address").enterText(email, {timeout:"2000"});
app.input("Password").tap({timeout:"2000"});
app.input("Password").enterText(_password, {timeout:"2000"});
app.button("login").tap({timeout:"2000"});
try {
app.image("Open").verify(); //if label exists
} catch(Exception) {
app.debug().print("Label not found");
}
app.image("Open").tap({timeout:"2000"});
app.table("left_drawer").selectIndex("8", {timeout:"2000"});
app.button("Yes").tap({timeout:"2000"});
app.image("Open").tap({timeout:"2000"});
};
but it is not working my script is still breaking what I want to do is that if the view doesn't exists the script won't break and start from top again for next data value.
Help is much appreciated. Thanks!!!
As far as i understood the problem here, if label does not exist then this
app.image("Open").tap({timeout:"2000"});
will also break. Try to put this as well in try block.
As
........
app.input("Password").enterText(_password, {timeout:"2000"});
app.button("login").tap({timeout:"2000"});
try {
app.image("Open").verify(); //if label exists
app.image("Open").tap({timeout:"2000"});
} catch(Exception) {
app.debug().print("Label not found");
}
app.table("left_drawer").selectIndex("8", {timeout:"2000"});
app.button("Yes").tap({timeout:"2000"});
app.image("Open").tap({timeout:"2000"});
Related
I am working on a personal project and I am using flutter to develop an app (cross platform) that reads in the user's health data from google fit (Android) or Apple Health. I am using this package and even the EXACT same code like in the documentation (I am currently only testing on Android):
Future fetchStepData() async {
int? steps;
// get steps for today (i.e., since midnight)
final now = DateTime.now();
final midnight = DateTime(now.year, now.month, now.day);
bool requested = await health.requestAuthorization([HealthDataType.STEPS]);
if (requested) {
try {
steps = await health.getTotalStepsInInterval(midnight, now);
} catch (error) {
print("Caught exception in getTotalStepsInInterval: $error");
}
print('Total number of steps: $steps');
setState(() {
_nofSteps = (steps == null) ? 0 : steps;
_state = (steps == null) ? AppState.NO_DATA : AppState.STEPS_READY;
});
} else {
print("Authorization not granted - error in authorization");
setState(() => _state = AppState.DATA_NOT_FETCHED);
}
}
Then I am calling this function with await and I also have inserted the correct permission in all Android Manifest files:
Also I set up an OAuth2 Client ID for the project and added my google account as a test user.
BUT THE FUNCTION SETS THE VARIABLE STEPS ALWAYS TO NULL? The boolean variable "requested" is true, so it seems like the actual connection is working?
I am really disappointed by myself guys and I really need help - THANK YOU!
I tried adding the correct android permissions, asking for permissions explicitly, different time intervalls but nothing worked for me, I always got a null value back.
I am trying to sign in anynomous on my android device in a game I have developed. When I run the game in the Unity Editor on my Macbook, everything runs smoothly and the database is update.
But when I compile and run it on my Samsung device, nothing happens, it just freezes. Does anyone have a clue why? I tried adding the sha1 key to the fingeprints of my project on Firebase, but no luck.
Here is the code:
private void anonymousSignIn()
{
auth = Firebase.Auth.FirebaseAuth
.DefaultInstance;
auth.SignInAnonymouslyAsync().ContinueWith(task => {
if (task.IsCanceled)
{
Debug.LogError("SignInAnonymouslyAsync was canceled.");
return;
}
if (task.IsFaulted)
{
Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
return;
}
user = task.Result;
Debug.LogFormat("User signed in successfully: {0} ({1})",
user.DisplayName, user.UserId);
print("User signed in");
removeUser();
});
print("Auth done");
}
private void prepareDatabase()
{
FirebaseApp.DefaultInstance
.SetEditorDatabaseUrl("mydatabaseadress/");
DatabaseReference reference =
FirebaseDatabase.DefaultInstance.RootReference;
string userId = "Erik";
User user = new User(userId, 24);
string json = JsonUtility.ToJson(user);
reference.Child("highscore").Child(userId).SetRawJsonValueAsync(json);
}
I'd need a stack trace at the point of the freeze or the Android logcat output to see what exactly is happening *I'd recommend this Unity plugin to help with parsing LogCat). Without knowing how all of this hooks together, it's hard to tell what "freeze" may mean in the context of your game or which call may be causing your problem. I do see a few possible issues:
1) SetEditorDatabaseUrl is not necessary, and I never use it in my own projects. I assume that "mydatabaseadress/" is a temporary value for this stack overflow question, but it's also an unnecessary potential bug surface if you only have one database in your project.
2) removeUser may be doing some work in Unity. For that reason, you should replace ContinueWith with ContinueWithOnMainThread (see this). That will also make sure that you get all of the necessary logging.
3) auth.CurrentUser will persist between runs of your game. Each call to auth.SignInAnonymouslyAsync will create a new user - even if one's already been registered. You should change your auth code to something like:
auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
if (auth.CurrentUser == null) {
auth.SignInAnonymouslyAsync().ContinueWithOnMainThread(task => {
And remember to do any important work (such as calling removeUser()) in an else.
4) In your prepareDatabase call, you have a hardcoded string userId = "Erik". If you have a database rule like:
{
"rules": {
"highscore": {
"$uid": {
".write": "$uid === auth.uid"
}
}
}
}
Then it will always be rejected.
5) Similarly, if you're not waiting for auth.SignInAnonymouslyAsync to complete before calling prepareDatabase, the default "auth != null" may automatically fail.
I hope that helps!
--Patrick
I am using react-native for Android app. And use axios as http library. When I try to send a Blob object through http post I will get below error:
HTTP Failure in Axios TypeError: One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property? We don't allow it, as this is an edge case that we do not support. This error is a performance optimization and not spec compliant.
Below is the code I used to add blob object on form data:
let data = new FormData()
data.append('image', decodeBase64Image(image));
below is the code to decode base64 image. And below code works fine in one of my website application.
export const decodeBase64Image = (dataURI) => {
let byteString;
if (dataURI === undefined) {
return undefined
}
if (dataURI.split(',')[0].indexOf('base64') >= 0)
byteString = atob(dataURI.split(',')[1]);
else
byteString = unescape(dataURI.split(',')[1]);
// separate out the mime component
let mimeString = ''
if (dataURI.split(',')[0] != undefined && dataURI.split(',')[0].split(':')[1] != undefined) {
mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
}
// write the bytes of the string to a typed array
let ia = new Uint8Array(byteString.length);
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ia], {type: mimeString});
}
The root of the problem is that the React Native devs made a performance optimization that is not spec-compliant (which is why the code works on your website, but not your React Native app). For more details, see the issue I opened here: https://github.com/facebook/react-native/issues/16814
As a workaround, you can use react-native-fetch-blob. I ran into the same error you did, and react-native-fetch-blob solved it for me.
There are Android and iOS applications, I have dynamical URI and I need to redirect Android and iOS users directly to mobile application via nginx, only if they use this link.
But I don't understand how to handle it without "logical and" or "inner if".
As I understand I have to solve two conditions:
if ($http_user_agent ~* '(iphone|ipod|nokia|аndroid)' ) {
rewrite ^ mobile_application://$host$request_id last;
}
and:
set $my_uri sign-up?invitation=$key #this key is dynamical
if ($request_id = '($my_uri)' ) {
rewrite ^ mobile_application://$host$request_id last;
}
So, I have no idea how to fix it.
set $targeted_mobile no;
if ($http_user_agent ~* "android|iphone|ipod") {
set $targeted_mobile yes;
}
location /deep-link/ {
if ($targeted_mobile = yes) {
rewrite ^/deep-link/(.*) mobile://www.aaa.com/$1 permanent;
}
rewrite ^/deep-link/(.*) https://$server_name/$1 permanent;
i am trying to do login application which takes id and password..when i click on logi button then it will connect to our local server by JSON..with the specified URL..the code is..
var loginReq = Titanium.Network.createHTTPClient();
loginReq.onload = function()
{
var json = this.responseText; alert(json);
var response = JSON.parse(json);
if (response.data.status == "success")
{ alert("Welcome ");
}
else
{ alert(response.data.status);
}
};
loginReq.onerror = function(event)
{
alert(event.toSource());
//alert("Network error");
};
loginBtn.addEventListener('click',function(e)
{ if (username.value != '' && password.value != '')
{
var url = 'our local url action=login&id='+username.value+'&pwd='+password.value;
loginReq.open("POST",url);
loginReq.send();
}
else
{
alert("Username/Password are required");
}
});
Here it is not connecting our URl..so it is entering into loginReq.onerror function...instead of loginReq.onload function..why it is throwing run time error.. The same code working fine with Iphone..
The Run Time Error is..
TypeError:Cannot call property toSource in object{'source':[Ti.Network.HttpClient],specified url} is not a function,it is a object.
This is wat the error..please let me Know...
Apparently the toSource() function does not exist in android, as it is an object. Try debugging and see what the object event contains.
You could do that by adding a line above the alert line, and adding a debug line to it.
Look in debug mode and see all variables
"toSource()" is not a documented function for either platform, and I also do not see it in the source for Titanium Mobile. If you aren't getting the error on iOS, I'm guessing it is because the error handler isn't getting called. Perhaps your emulator or device does not have internet access, whereas your iOS simulator or device does?
Regardless, error handling in the HTTPClient normally looks something like this:
loginReq.onerror = function(e)
{
Ti.API.info("ERROR " + e.error);
alert(e.error);
};