When running the Calabash tests I get an error during the Before phase but the report exits with 0 code. It says that all the tests were failed because all the steps were skipped but the HTML report is green.
How can I make the report show that there was an error?
Updated: The exit code is correct. If it fails it returns a non 0 code. The problem is the html formatter. I'm running it with the following flag:
--format=html --out ./target/calabash-reports.html
Use
screenshot_and_raise "Error description"
line in side ruby step definitions where you want to raise the error
Eg:
Then /^I (?:press|touch) list item number (\d+)$/ do |index|
index = index.to_i
screenshot_and_raise "Index should be positive (was: #{index})" if (index<=0)
touch("tableViewCell index:#{index-1}")
sleep(STEP_PAUSE)
end
Related
So some background information. I am tasked with exploring writing cross platform native applications using Xamarin. Seems pretty basic so far and I'm liking what I'm reading. I have my Visual Studio 2015 Enterprise all set up and my remote mac configured on the network. I created a cross platform native app through the project creation wizard in Visual Studio. When I launch a debug session for the iOS app, it does start the target app in the simulator on the remote Mac. However, it never actually thinks it is running fully. It will hang at this output:
Launching 'PersonalProject.iOS' on 'iPhone 6 iOS 10.2'...
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/Xamarin.iOS.dll
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/System.dll
Thread started: #2
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/PersonalProject.iOS.exe
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/System.Xml.dll
Eventually, it will fail with something along these lines:
The app has been terminated.
Launch failed. The app 'PersonalProject.iOS' could not be launched on 'iPhone 6 iOS 10.2'. Error: An error occurred while executing MTouch. Please check the logs for more details.
I've checked the log file in question and it contains nothing more than the same exact phrase.
If I try and put a simple line of Console writing on the action of pressing the button:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
Button.AccessibilityIdentifier = "myButton";
Button.TouchUpInside += delegate {
var title = string.Format ("{0} clicks!", count++);
Button.SetTitle (title, UIControlState.Normal);
Console.WriteLine(string.Format("{0} clicks!"));
};
}
the debug session actually errors on this line 17 (UIApplication.Main) in the Main.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace PersonalProject.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main (string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main (args, null, "AppDelegate");
}
}
}
With Unhandled exception error:
Unhandled Exception:
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Error while resolving expression: One or more errors occurred.
If I don't have the console log it will launch the app, but still hanges at those Loaded assembly lines. At this point, I can't hit any breakpoints in my code. I tried adding a breakpoint in the shared code for the button click but it would never hit it, even though the action was being carried out by the simulator.
I'm completely at a loss for how to proceed. I haven't touched anything out of the box of the wizard creation. I was hoping I could at least see the starter project working.
Any help is appreciated.
You are using
Console.WriteLine(string.Format("{0} clicks!"));
The {0} is a placeholder for a value to output, but you never specify that value, that's why you are getting an error.
Use something like this instead:
Console.WriteLine(string.Format("{0} clicks!", count));
or in C#6 syntax:
Console.WriteLine($"{count} clicks!");
I want to create an AVD (Android Virtual Device) through command line in python. For that, I need to pass a string n to the stdin. I have tried the following
emulator_create = str(subprocess.check_output([android,'create', 'avd', '-n', emulator_name, '-t', target_id, '-b', abi],stdin=PIPE))
emulator_create.communicate("n")
but it raises the following error
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/home/fahim/Android/Sdk/tools/android', 'create', 'avd', '-n', 'samsung_1', '-t', '5', '-b', 'android-tv/x86']' returned non-zero exit status 1
Process finished with exit code 1
What can I do?
There's something not working with your example. subprocess.check_output() returns the output from the child process you want to execute, not a handle to this process. In other words you get a string object (or maybe a bytes object) which you cannot use to manipulate the child process.
Probably what happens is that your script, using subprocess.check_output(), will execute the child process and wait until it is finished before continuing. But since you are never able to communicate with it, it will finish with a non-zero return value which will raise the subprocess.CalledProcessError
Now, using grep as an example of a command that waits on the standard input to execute something (since I don't have an Android Virtual Device creator installed) you could do this:
#!/usr/bin/env python2.7
import subprocess
external_command = ['/bin/grep', 'StackOverflow']
input_to_send = '''Almost every body uses Facebook
You can also say that about Google
But you can find an answer on StackOverflow
Even if you're an old programmer
'''
child_process = subprocess.Popen(args=external_command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
universal_newlines=True)
stdout_from_child, stderr_from_child = child_process.communicate(input_to_send)
print "Output from child process:", stdout_from_child
child_process.wait()
It will print "Output from child process: But you can find an answer on StackOverflow", which is the output from grep.
In this example, I have
Used the class subprocess.Popen to create an handle to the child process
Setting arguments stdin and stdout with the value subprocess.PIPE to enables us to communicate later on with this process.
Used its .communicate() method to send a string to its standard input. In the same step, I retrieved its standard output and standard error output.
Printed the standard output retrieved in the last step (just so to show that it is actually working)
Waited that this child process is finished
In Python 3.5, it's even simpler:
#!/usr/bin/env python3.5
import subprocess
external_command = ['/bin/grep', 'StackOverflow']
input_to_send = '''Almost every body uses Facebook
You can also say that about Google
But you can find an answer on StackOverflow
Even if you're an old programmer
'''
completed_process_result = subprocess.run(args=external_command,
input=input_to_send,
stdout=subprocess.PIPE,
universal_newlines=True)
print("Output from child process:", completed_process_result.stdout)
In this example, I have:
Used the module function subprocess.run() to execute the command.
The input argument is the string we send to the standard input of the child process
The return value is used later on to retreive the output of the child process
Now you have to adapt this code to your situation.
Scenario : I have different types of ads coming . One can be clicked on a button and other can be clicked on the whole ad.
I have to test when an ad comes , the first test by clicking on the button , if it doesn't work , click on the other type. In appium , in the first if condition if it doesn't find element it will fail the test.
How can I test multiple conditions before it declares it failed.
There're many ways of doing it. In Python I would go with something' like:
locators = ['.someClass', '#someID']
for locator in locators:
el = self.driver.find_elements_by_css_selector(locator)
if len(el) == 1:
break
elif len(el) == 0:
el = None
else:
self.fail('multiple elements: %s found: %d' % locator, len(el))
self.assertIsNotNone(el, '> 1 matches found on page: %s' % locator)
el.click()
Basically if the locator is not found on the page, then we set el as None and try out another locator.
If a locator ( in your case let's say button )is found than the method break. If locators found > 1, then it fails.
You must define unique locators for this function to work.
did anyone notice that on Android - Ti SDK 5.4.0.GA is showing many output at console on all modes like Trace, Debug, Info, Warning, Error.
I have not tried it for Wi-Fi off state, but it is showing such lines every second when the device is connected to Wi-Fi and my console filled up with 100 lines in just few seconds:
[INFO] : D/StatusBar.MSimNetworkController( 1166): getNumberOfActiveSim:0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getPhoneSignalIconList: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getDataSignalIconId: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0 iconLevel = 4
[INFO] : D/StatusBar.MSimNetworkController( 1166): updateTelephonySignalStrength: iconLevel=4
Can anyone suggest any solution as this is getting quite annoying and I cannot focus on the console output from code due to too many above logs?
Update
Finally I found a solution to this problem:
https://github.com/appcelerator/titanium_mobile/pull/8754
Logs that contain a dot (or any other character besides letters) won't be caught in the don't show part!
The PR will change the RegEx rule to match any character.
Old solution:
Check the output of ti config cli.logLevel and set it to info
Might solve the problem for you.
I'm facing the same issue and I use monitor with this custom filter:
^(?!(WifiStateMachine|WIFI_UT|AppOps|GraphicsStats|RegisteredNfcid2Cache|Wifi|NotifUtils|WIFI|usbnet|Ethernet|FaceDetectTask|RecentsTaskLoadPlan|MorningBundlePlugin|SocialManagerService|PhoneApp|LoadDialerReceiver|Icing|Herrevad|Finsky|StatusBarManagerService|DropBoxEntryAddedChimeraService|ClearcutLoggerApiImpl|AlarmManager|GCoreUlr|GCoreFlp|APSAnalyticsService|QCNEJ|NetworkStats|IpReachabilityMonitor|Nfcid2RoutingManager|ls|WifiManager|libc|dex2oat|ACRA|HtcMirrorLinkAmsListener|LOWI-Scan|DownloadManagerWrapper|wpa_supplicant|QCALOG|WIFI_ICON|HtcWrapCustomizationManager|gdlights|PowerUtils|ExtremePowerSave|WifiService|FrameworkListener|MediaRouterServie|DotMatrix|PowerUI|PMS|XTCC-5.1.0.7|NetworkManagement|HtcPowerSaver|BatteryControlle|NetLinkSocketObs|WifiController|NetlinkSocketObs|BatteryService|UsbnetService|DeviceIdleControler|Keyboard.Facilit|xiaomi|qdlights|SensorService|AutoSetting|HtcWifiRssiMonitor|HtcWifiDataStallTracker|WifiAutoJoinController|HtcWLD_v5.1.0|WifiMonitor|WifiConfigStore|StatusBar.NetworkController|CwMcuSensor|BrcmNfcJni|DATA_ICON|TelephoneCallback|ContactMessageStore|HtcUPManager|ScreenOnOffReceiver|DeviceIdleController|QSPanel|NetworkPolicy|GpsLocationProvider|SensorManager|SmartNS_PSService|PhoneStatusBar|ScrimController|Settings|LocationManagerService|getVisibilityByRssi|NetworkController.WifiSignalController|GAv4|IntegrityChecker|KernelCpuSpeedReader|KernelWakelockReader|BatteryStatsImpl|WeatherUtility|WeatherTimeKeeper|PNP_UPDATERD|DsService|PathParser|StatusBarManagerServiceHtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|HtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|WSP|Babel|CityCodeHelper|TetherStatsReporting|TelephonyCallback))
Put this in by Log Tag in a new filter. My device is a HTC A9, a very log-noisy device!
If you still see rows you don't want to just put attach the tags with |tagname
I am trying to display opencore logs. I have already tried the ff. but still logs are not showing in the logcat.
1. created pvlogger.txt in sdcard and still no use.
# echo 8 > /sdcard/pvlogger.txt
2. Edited the PV_LOG_INST_LEVEL from 0 to 5 in the pvlogger.h file but it causes the compilation to fail.
"/android_log_appender.h:75: error:" format not a string literal and no format argument"
So I have just commented out Line 75, although it compiled successfully, opencore logs are still not showing in the logcat.
Is there anyone who were able to display the opencore logs?
Thanks in advance.
artsylar
I had this issue three months ago. Please don't comment out LOGE(stringbuf) in /android_log_appender.h, otherwise there is no log out.
LOGE("%s", stringbuf) instead of LOGE(stringbuf).
1. created pvlogger.txt in sdcard and still no use.
`# echo 8 > /sdcard/pvlogger.txt`
2. Edited the PV_LOG_INST_LEVEL from 0 to 5 in the pvlogger.h.
3. ENABLE_PV_LOGGING from 0 to 1 in the pvlogger.h.
4. LOGE("%s", stringbuf) instead of LOGE(stringbuf) in /android_log_appender.h.
Wish you success!
After trial and errors, I was finally able to show the OpenCore log messages! Here's what I did although I do not know yet if steps 4 and make options are needed.
Added #define PV_LOG_INST_LEVEL 5 to \android\external\opencore\android\thread_init.cpp file.
To solve the "/android_log_appender.h:75: error:" format not a string literal and no format argument" error, just edit \external\opencore\android\android_log_appender.h line 75 from LOGE(stringbuf) to LOGE("%s", stringbuf)
compile the code.
make ENABLE_PV_LOGGING=1
create pvlogger.txt in sdcard.
# echo 8 > /sdcard/pvlogger.txt