calabash-ios: The app hangs when running automation - ios

I'm using the simulator (iOS 9.0).
I’m running the command: device_target=UDID cucumber
The simulator starts and the app is loading, but then the console hang for few min until time out.
I have the same issue when I run it manually in the console:
calabash-ios console
start_test_server_in_background
The error that I get is:
#<RuntimeError: Timed out connecting to Calabash server after 10 retries. Make sure it is linked and App isn't crashing>
RuntimeError: Unable to make connection to Calabash Server at http://localhost:37265/`
Make sure you don't have a firewall blocking traffic to http://localhost:37265/.
running the command curl http://localhost:37265 and get the error - curl: (7) Failed to connect to localhost port 37265: Connection refused
what I’m missing?
(the app developed in Xamarin)

device_target=UDID cucumber
This is not doing what you expect. Calabash responds to DEVICE_TARGET not device_target.
My best guess is that you need to check whether your .app is linked with Calabash.
Please see these two pages:
https://github.com/calabash/calabash-ios/wiki#reporting-problems
https://github.com/calabash/calabash-ios/wiki/Updating-your-Calabash-iOS-version#what-version-of-the-server-is-embedded-in-my-app

Related

How do I make sure ports 8200..8299 for UIAutmator2 are free'd up after killing Appium?

I'm running Appium 24/7 on a Windows machine to perform automated tests. I'm running these tests via AVD on an emulator with Android 10. For my test, I give the correct Capabilities and runs functionally great. But after a few hours/days I get the follow error:
UnknownError: An unknown server-side error occurred while processing the command. Original error:*Cannot find any free port in range 8200..8299}. Please set the available port number by providing the systemPort capability or double check the processes that are locking ports within this range and terminate these which are not needed anymore at getResponseForW3CError at asyncHandler.
When my code is executed, I make sure the finally in try executes the AppiumDriverLocalService.stop(); method to kill Appium. My feeling says this does somehow not free up any ports for UIAutomator2 (which you can configure, but I have not configured, through systemPort capability.
} finally {
driver.closeApp();
service.stopServer();
System.exit(0);
}
Why does Appium not free up any ports for UIAutomator2 in the range 8000-8299 after stopping the service?
Android Debug Bridge version 1.0.40
Appium version 1.20.2
Android 10
PS I know of the adb command adb -s $UDID forward --remove-all but does this solve the real issue, I don't want to execute a Java Process each time
Update - Fix 2-3
I have fixed the issue by changing the finally clause to execute the following methods in order:
} finally {
AndroidDriver.quit();
AppiumDriverLocalService.stopServer();
In order to free up the port 8200..8299, AndroidDriver must be quit as UIAutomator2 is linked to this. The AppiumDriverLocalService will kill/forward/free this port and UIAutomator2, after this I can freely stop the server:
[ADB] Removing forwarded port socket connection: 8203
This issue is a good example of your problem. As you can see, Appium team is closing it as a Not A Bug.
Reason is obvious: Appium is not responsible for managing ports, it relies that your system has some free in required (by Appium code) range.
systemPort is used to connect to appium-uiautomator2-server, by default is 8200. Basically Appium selects one port from 8200 to 8299 for appium-uiautomator2-server. However, when you run tests in parallel, you must adjust the port to avoid conflicts. If you are not, you should be safe in 99% cases with the default.
Restart the system (assuming it will clear ports) and run tests. Check Appium server logs for any errors on closing session. It could be that issue is related to ADB setup or permission issue, and UI2 server is not stopped properly.
If so, port remains in use. And it is not Appium to deal with cleanup. I'm not sure that adb command you mentioned is a good 100% guaranteed way to do it.
I would just add a shell script that is executed before Appium server start to clean ports in 8200-8299 range and forget this problem.
killall -9 node - to kill all appium running internally and at root level
and adb kill-server - to kill the abd server by running this it resolved the above issue for me , hope may help someone

Could not connect to development server. Error while running

I have tried to restart the server with npm start, npx react-native run-ios, npx react-native start. Those commands don't work for me. Help me out to run this project its a project created with npx react native init projectName.
warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
The error shown on the emulator
Run adb reverse tcp:8081 tcp:8081 in your terminal then reload in the terminal after running yarn start or npm start, then reload. I hope this is helpful.
I had the same problem and spent hours working on it. I figured out that METRO which is run using this command: npm start or this one npx react-native start couldn't find its way to my mobile app.
one of the solutions that I wasn't totally pleased of was this: a solution that works but has flows
but that workaround wasn't perfect because I had to re-run the command every single time I make a change. So after further researches I found out that the port 8081 is used by an another application that METRO is sending information to ( this is only my guess ). so:
I run the following:
netstat -aon | findstr 8081 // to get the PID of the application that is running on 8081 port
I opened task manager ( CRTL + ALT + del ) under the service section I looked up any
application which uses the PID that matches the one given by the command I ran and I have
forced stopping it.
retried npx react-native start and npx react-native run-android on my project
and the magic happened. It auto refreshes with every change, I wish it helps you.
This is from the docs:
Method 2: Connect via Wi-Fi
You can also connect to the development server over Wi-Fi. You'll
first need to install the app on your device using a USB cable, but
once that has been done you can debug wirelessly by following these
instructions. You'll need your development machine's current IP
address before proceeding.
Open a terminal and type /sbin/ifconfig to find your machine's IP address.
Make sure your laptop and your phone are on the same Wi-Fi network.
Open your React Native app on your device.
You'll see a red screen with an error. This is OK. The following
steps will fix that.
Open the in-app Developer menu.
Go to Dev Settings → Debug server host for device.
Type in your machine's IP address and the port of the local dev
server (e.g. 10.0.1.1:8081).
Go back to the Developer menu and select Reload JS

Travis CI - Unable to remove port forward Error executing adbExec

I am trying to setup automated tests for an android app using Appium (npm version) but I keep getting the error
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[UiAutomator2] Unable to remove port forward 'Error executing adbExec. Original error: 'Command '/usr/local/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp\:8200' exited with code 1'; Stderr: 'error: listener 'tcp:8200' not found'; Code: '1''
I have looked around google for ages but havnt been able to find any solution that has actually worked for me, so far totalling 50 failed builds.
If i run the commands on my local machine it works fine but within travis I have no such luck unfortunately. I am new to setting up appium so it could be something minor im not understanding.
A gist of my travis.yml file is here
Distribution:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
Thanks in advance.
tcp:8200 is not forwarded and there should be no forwards.
try with adb forward --remove-all, when not knowing which port it is
... if it's even required to remove any forward.
After looking at the logs, I understand that the emulator is not ready to allow UiAutomator to get deployed properly.
So to make sure that emulator is ready, you can use avdLaunchTimeout and avdReadyTimeout by passing 60000 ms to both in your desired capabilities.
Once the emulator is ready, you won't get this error.

React-Native Could not connect to development server

I've been testing my project on my iPhone6s and it worked perfectly. But today Xcode and Node.js keeps giving me the 'Unable to execute JS call: __fbBatchedBridge is undefined' error.
I'm sure the IP address is correct, my phone is under the same Wifi network with server. The simulator works fine with the server ip. To test if it is something wrong with the project I start another AwesomeProject and changed the IP but still not working. Anyone know any possible solutions?
I faced the same issue in my office Wifi network connection also. This is because of the router configuration. There are two ways to make it work.
Expose the local server using ngrok. But, It will be slow since it is sending everything to server.
Connect your phone using USB cable and type the following command in the computer adb reverce tcp:8081 tcp:8081

Error when launching using appium

I am getting an error when I am launching the appium for android. I started node.js by double ckicking node.js then I gave the path of my apk file and then clicked on launch buttonand in console i got following error:
Starting Node Server
Starting Appium in pre-launch
Pre-launcing app
Using fast reset?false
No app-activity desired capability or server param.Parsing from apk.
No app-package desired capability or server param.Parsing from apk.
Using local app from command line: C:\Users\ssharma\lowes-android-app-Wolverine-Sprint6-2014-04-29_17-03-13.apk
Creating new appium session 4aa75228-984f-46f7-8b09-50221dc19875
starting android appium
Preparing device for session
Checking whether app is actually present
Checking whether adb is actually present
Sent shutdown command,waiting for UiAutomator to stop...
Uiautomator did not shut down fast enough calling it gone
Error:
Node Server Process Ended
Please help me in this issue.
What machine are you running on ? On windows you can use exe and on mac you can use app and then pass correct capabilities from appium client.

Resources