Displaying last 3 digits of a order number
Hi, I'm trying to test a test case where I have to pass the last three digits of an order number that I have created from another groovy script.
Below is my original script that creates the order number
int a = 9 nr = "N" for(i = 0; i < 7; i++) { random = new Random() randomInteger= random.nextInt(a) nr = nr + randomInteger } //return nr testRunner.testCase.setPropertyValue("OrderNumber",nr)
It creates an order Number for example N0382254.
Now in another script I want get the last three digits of that order number and save it into a property.
How can I call the original script and then get the last 3 digits?
Any help will be highly appreciated. Thanks!
The issue got fixed after performing the below steps:-
1. Downloaded the GPS test app the link which was given by one of the SmartBear representatives.
Link - https://play.google.com/store/apps/details?id=com.chartcross.gpstest
2. Check the In View and In Use count.
3. If the count is 0 then killing the adb instance. So that count becomes greater than 0.
4. Then executing the script.
5. Created a separate script to disable the mock location rather than disabling in the same script.
6. Disabling the mock location in the same script was just setting the location first and then disabling it and on UI you couldn't see any change.
7. So in short, killing the adb instance and checking for the fix in GPS test app before executing the script fixed the issue.
Code snippet:-
function MockGPSLocation()
{
var Longt, Lat, Alt, Acc, Gps;
// Enable GPS
Mobile.Device().GPS.GPSEnabled = true;
Longt = Mobile.Device().GPS.Location.Longitude;
Lat = Mobile.Device().GPS.Location.Latitude;
Log.Message("Original Longitude: "+Longt);
Log.Message("Original Latitude: "+Lat);
// Enable the "Allow mock locations" property
Mobile.Device().GPS.AllowMockLocations = true;
Longt = 174.8367068133983;
Lat = -36.87015422083155;
Alt = Mobile.Device().GPS.Location.Altitude;
Acc = Mobile.Device().GPS.Location.Accuracy;
// Specify a mock location
Mobile.Device().GPS.SetLocation(Longt,Lat,Alt,Acc);// Output the location data
Longt = Mobile.Device().GPS.Location.Longitude;
Lat = Mobile.Device().GPS.Location.Latitude;
Alt = Mobile.Device().GPS.Location.Altitude;
Acc = Mobile.Device().GPS.Location.Accuracy;
Gps = Mobile.Device().GPS.GPSEnabled;
Log.Message("Longitude: "+Longt);
Log.Message("Latitude: "+Lat);
Log.Message("Altitude: "+Alt);
Log.Message("Accuracy: "+Acc);
Log.Message("GPSEnabled: "+Gps);}
function DisableMockLocation()
{
Mobile.Device().GPS.AllowMockLocations = false;
}