alttester / AltTester-Unity-SDK

AltTester Unity SDK is an open-source UI driven test automation tool that helps you find objects in your game and interacts with them using tests written in C#, Python, Robot or Java.
https://alttester.com/docs/sdk/latest/home.html
GNU General Public License v3.0
60 stars 7 forks source link

AltUnityServer not running on port 13001 on both of platforms (iOS and Android) #9

Closed AltTesterBot closed 1 year ago

AltTesterBot commented 1 year ago

I have an app generated by Unity( iOS and Android). 

I started an Appium server. I wrote the small test on python (on both of platforms Android and iOS) and I had an error (AltUnityServer not running on port 13001) I tested on both of platforms Android and iOS on simulators and real devices.

import unittest

import os
from self import self
from altunityrunner import AltrunUnityDriver
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction

PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(__file__), p)
)

class SampleAppiumTest(unittest.TestCase):
    self.caps = {}
    self.caps["platformName"] = "Android"
    self.caps["platformVersion"] = "4.3"
    self.caps["deviceName"] = "Samsung GT-l9300"
    self.caps["app"] = ".../build.apk"
    self.caps["noReset"] = True

    self.wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', self.caps)
    self.altdriver = AltrunUnityDriver(self.wd,  "Android")
/.../first.py
Staring tests on Android
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 60 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 55 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 50 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 45 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 40 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 35 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 30 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 25 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 20 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 15 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 10 secs)...
[Errno 61] Connection refused
AltUnityServer not running on port 13001, retrying (timing out in 5 secs)...
Traceback (most recent call last):
  File ".../first.py", line 18, in <module>
    class SampleAppiumTest(unittest.TestCase):
  File ".../first.py", line 27, in SampleAppiumTest
    self.altdriver = AltrunUnityDriver(self.wd,  "Android")
  File ".../PycharmProjects/first/venv/lib/python2.7/site-packages/altunityrunner/runner.py", line 97, in __init__
    self.TCP_PORT) + '``?')
Exception: AltUnityServer not running on port 13001, did you run ``adb forward tcp:13001 tcp:13000`` or ``iproxy 13001 13000``?

Process finished with exit code 1

You can find the original issue from GitLab here.

AltTesterBot commented 1 year ago

Thanks for the bug report! I would need your help a bit more to narrow down the problem, if you have the time, could you please check the following?

Did you add the AltUnityTester prefab to your scene in Unity? Basically, this part of the setup in the Readme:

Setting up your Unity Game/App

To use the AltUnityDriver, you need to:

  1. Import the AltUnityTester asset/package into your Unity project:

    • if you use a downloaded Unity package, go to Assets->Import Package -> Custom Package in Unity Editor and select the AltUnityTester.unitypackage file
    • if you dowloaded it from the Unity Asset store, just go to your Asset Store Downloads Manager from Unity Editor and import the package.
  2. Add the AltUnityDriver prefab (from AltUnityTester/Prefab folder) to your main scene in the game/app, the one that will be first shown to the users. By default, this will use 13000 as the port for the socket connection. If you want to change this, you can update the port value number in Unity Editor in the Inspector.

Did you run through these steps on your local machine, where you are running the tests?

Setting up your local machine

To run your tests on iOS and Android, you need to have Appium installed. Info on that is available here: http://appium.io/docs/en/about-appium/getting-started

For iOS, to run the tests on real iOS device, please make sure you also go through this: http://appium.io/docs/en/drivers/ios-xcuitest/

To connect to the AltUnityDriver socket connection, with the device connected to your computer, you will need to forward the tcp port from the device to your computer:

To do this on Android, use:

adb forward tcp:13001 tcp:13000 where first port (13001 in the example above) is the port on your computer and the second port (13000 in the example above) is the AltUnityDriver port. This is 13000 by default.

To do this on iOS, use:

iproxy 13002 13000 where first port (13002 in the example above) is the port on your computer and the second port (13000 in the example above) is the AltUnityDriver port. This is 13000 by default.

The iproxy command is installed as part of the libimobiledevice package that you should have already installed when setting up your iOS environment (http://appium.io/docs/en/drivers/ios-xcuitest-real-devices/)

Do you have a Development build for the application? In Unity, is "Development Build" selected when you check the Build Settings?


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Thank you for the answer. Yes, I added AltUnityTester prefab to my scene in Unity using part of setup. I set up my local machine.

I tested with Development build and without it and I had the same issue. Added to attachments Appium logs.


[Logcat] Starting logcat capture
[AndroidDriver] Pushing unlock helper app to device...
[ADB] Getting install status for io.appium.unlock
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","pm","list","packages","io.appium.unlock"]
[ADB] App is installed
[ADB] Getting package info for io.appium.unlock
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","dumpsys","package","io.appium.unlock"]
[ADB] Checking whether aapt is present
[ADB] Using aapt from .../Library/Android/sdk/build-tools/27.0.3/aapt
[ADB] The installed 'io.appium.unlock' package does not require upgrade ('2.0.0' >= '2.0.0')
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","getprop","ro.build.version.release"]
[ADB] Current device property 'ro.build.version.release': 4.3
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","wm","size"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","getprop","ro.product.model"]
[ADB] Current device property 'ro.product.model': GT-I9300
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","getprop","ro.product.manufacturer"]
[ADB] Current device property 'ro.product.manufacturer': samsung
[AndroidDriver] Parsing package and activity from app manifest
[ADB] Using apkanalyzer from .../Library/Android/sdk/tools/bin/apkanalyzer
[ADB] Starting '.../Library/Android/sdk/tools/bin/apkanalyzer' with args ["-h","manifest","print",".../Documents/appodeal/unity/New Unity Project/build.apk"]
[ADB] Using the alternative activity name detection method because of: Command '.../Library/Android/sdk/tools/bin/apkanalyzer -h manifest print '.../Documents/appodeal/unity/New Unity Project/build.apk'' exited with code 1
[ADB] Checking whether aapt is present
[ADB] Using aapt from .../Library/Android/sdk/build-tools/27.0.3/aapt
[ADB] Extracting package and launch activity from manifest
[ADB] Package name: 'com.appodeal.test'
[ADB] Main activity name: 'com.unity3d.player.UnityPlayerActivity'
[AndroidDriver] Parsed package and activity are: com.appodeal.test/com.unity3d.player.UnityPlayerActivity
[ADB] Getting install status for com.appodeal.test
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","pm","list","packages","com.appodeal.test"]
[ADB] App is installed
[ADB] Getting package info for com.appodeal.test
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","dumpsys","package","com.appodeal.test"]
[ADB] Checking whether aapt is present
[ADB] Using aapt from .../Library/Android/sdk/build-tools/27.0.3/aapt
[ADB] The installed 'com.appodeal.test' package does not require upgrade ('1.0.0' >= '1.0.0')
[AndroidDriver] Extracting strings from apk .../Documents/appodeal/unity/New Unity Project/build.apk undefined /var/folders/7v/rjq1bqj50v706mvxvb15dklc0000gn/T/com.appodeal.test
[ADB] Extracting strings for language: default
[ADB] Device API level: 18
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","getprop","persist.sys.language"]
[ADB] Current device property 'persist.sys.language': ru
[ADB] Reading strings from converted strings.json
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","push","/var/folders/7v/rjq1bqj50v706mvxvb15dklc0000gn/T/com.appodeal.test/strings.json","/data/local/tmp"]
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","forward","tcp:4724","tcp:4724"]
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state 'starting'
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","push","/Applications/Appium.app/Contents/Resources/app/node_modules/appium-android-bootstrap/bootstrap/bin/AppiumBootstrap.jar","/data/local/tmp/"]
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.appodeal.test","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] Moving to state 'online'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] json loading complete.
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Getting connected devices...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","dumpsys","window"]
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Device API level: 18
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","am","start","-W","-n","com.appodeal.test/com.unity3d.player.UnityPlayerActivity","-S"]
[ADB] Waiting up to 20000ms for activity matching pkg: 'com.appodeal.test' and activity: 'com.unity3d.player.UnityPlayerActivity' to be focused
[ADB] Possible activities, to be checked: 'com.unity3d.player.UnityPlayerActivity'
[ADB] Getting focused package and activity
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","dumpsys","window","windows"]
[ADB] Found package: 'com.appodeal.test' and fully qualified activity name : 'com.unity3d.player.UnityPlayerActivity'
[Appium] New AndroidDriver session created successfully, session d04ac9a5-0dce-4fca-a8fc-d8139db4e0f1 added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1524062494514 (17:41:34 GMT+0300 (EEST))
[MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.3","deviceName":"Samsung GT-l9300","app":".../Documents/appodeal/unity/New Unity Project/build.apk","platformName":"Android","noReset":true},"platformVersion":"4.3","deviceName":"4df1697a2b2e7f8d","app":"/.../Documents/appodeal/unity/New Unity Project/build.apk","platformName":"Android","noReset":true,"deviceUDID":"4df1697a2b2e7f8d","deviceScreenSize":"720x1280","deviceModel":"GT-I9300","deviceManufacturer":"samsung","appPackage":"com.appodeal.test","appWaitPackage":"com.appodeal.test","appActivity":"com.unity3d.player.UnityPlayerActivity","appWaitActivity":"com.unity3d.player.UnityPlayerActivity"}
[HTTP] <-- POST /wd/hub/session 200 15643 ms - 939 
[BaseDriver] Shutting down because we waited 60 seconds for a command
[AndroidDriver] Shutting down Android driver
[ADB] Getting connected devices...
[Appium] Closing session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'
[Appium] Removing session d04ac9a5-0dce-4fca-a8fc-d8139db4e0f1 from our master session list
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","am","force-stop","com.appodeal.test"]
[ADB] Pressing the HOME button
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","input","keyevent",3]
[AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":"OK, shutting down","status":0}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[AndroidBootstrap] [UIAUTO STDOUT] Time: 64.814
[AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[AndroidBootstrap] Received command result from bootstrap
[UiAutomator] Shutting down UiAutomator
[UiAutomator] Moving to state 'stopping'
[UiAutomator] UiAutomator shut down normally
[UiAutomator] Moving to state 'stopped'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Moving to state 'stopped'
[Logcat] Stopping logcat capture
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running '.../Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4df1697a2b2e7f8d","shell","am","force-stop","io.appium.unlock"]
[AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.

---
<sub>You can find the original comment from GitLab [here](https://gitlab.com/altom/altunity/altunitytester/-/issues/10#note_69177334).</sub>
AltTesterBot commented 1 year ago

Thank you, that all looks good. Would it be possible to also get the Android logcat? You can save it to a file using this command:

adb logcat -f logcat.txt


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Added to attachments.

logcat.txt


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

The logs show that the AltUnityTester starts correctly inside the game, so the issue must be on the other side. It could be a firewall problem?

I can suggest a few more things:

  1. After you forward the ADB port using adb forward tcp:13001 tcp:13000 command, try to restart the game on the device and check if the connection really works. I'm not sure what operating system you are on, but you could try: telnet localhost 13001 to see if you can connect on the socket. (On Mac, you can install telnet with brew install telnet if you don't have it already.) Or you could just try to go to "http://localhost:13001" in your browser - if the connection is open, you should see the page keeps loading instead of just saying it cannot connect. Do any of these work?

  2. Try to get the device's IP address and connect to that directly in your tests, if your device is on the same Wi-Fi network as the local machine that you run the tests from. So, if the device has the IP address 192.168.1.123, try to create the AltUnityDriver like this in the Python tests:

    self.altdriver = AltrunUnityDriver(self.driver, self.platform, TCP_IP="192.168.1.123", TCP_FWD_PORT=13000)

Also if you want you can find me on Skype with ru_cindrea, we could maybe discuss it more easily there and try to solve the problem.


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Hi,

I had this same problem but fixed it with the following:

In AltSocketServer.cs in the Unity package the device IP address is set to "127.0.0.1", if you change it to the device's ip address as it appears on the network (e.g. "192.168.0.20") then you should be able to connect to the socket from another device.

Bex

-- edit: Removed incorrect information regarding switching TCP ports, I was confused! The former point still stands though


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

I ran into this issue as well during my initial trial. Following the thread of @bexelfee above I found that if I modified the server endpoint setup to use IPAddress.Any rather than localhost (127.0.0.1) it resolved the issue for me. I guess there are situations where adb forward doesn't map the tcp calls to localhost on the device?

this.localEndPoint = new IPEndPoint(IPAddress.Any, this.portNumber);

You might want to give that a try and see if it works in all cases. More info can be found under the "Remarks" section of the TcpListener class here: https://msdn.microsoft.com/en-us/library/c6z86e63(v=vs.110).aspx.


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Can someone explain where else 13001 is defined? I am forwarding the port but still hit this issue. What server did I set up that takes 13001 as a port config (or is it a default?)?


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Ah I think I see now. Forwarding the port is supposed to allow access to the device by sending traffic to localhost 13001 on the computer. In the e.g. python test client script you specify 13001 when you construct AltUnityDriver to connect to the device. The device listens on 13000 which should be traffic forwarded from the 13001 port that the python test client script sends to. The python test client script also uses 4723 or whatever your appium server is set to when you call webdriver.Remote().

Okay it turns out my problem was that I did not know that in order to try new code on the device, you have to copy the apk to the device and install it manually. I also learned that by default adb logcat -f logcat.txt won't work on most devices because that attempts to write to the device OS system root which is generally not allowed. Instead I used adb logcat > logcat.txt which dumps it to a text file in your current directory on your desktop computer. Also I learned that you don't get to see the unity debug output just by running the app and saving logcat, you have to do an actual test (appium must be instrumenting something) either with py.test or python mytest.py in order to see the Unity debug output. I only tried development/debug build so that may be required too. I use python mytest.py while writing tests because it lets me see my python print() statements, while py.test does not.

As of this week I was only able to get this working in Unity2018.2.8f1 by uninstalling python 3 and installing python 2.7 as it comes through from appium python client recommended steps. Appium desktop didn't seem to work so I installed the npm command line version. I had to run npm --add-python-to-path='true' --debug install --global windows-build-tools and then add C:\Users\<username>\.windows-build-tools\python27\ manually so both it and C:\Users\<username>\.windows-build-tools\python27\Scripts were added to PATH before I could install pip and then finally run pip install -U pytest and pip install altunityrunner==0.2.3 (newer altunityrunner did not compile for me, possibly because of having python 3 only installed) though probably another decent python installer would have worked too. I had to roll back to the unitypackage file from commit 32c572a6ac47c49b566202cef75315e9159d910f in this repo.

Here is the test I used (based on the adventure game testing youtube video) which would not work until I had tweaked one or two things (e.g. the new self.platform parameter). adventure-tests.py

I hope this helps others who come along trying to get this working on Windows. Maybe some of this would be good to add to the main readme? Let me know if you want a merge request for that and if so which points you think would be relevant to others. Thanks to those that helped make this awesome tool!


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Is it possible to run to a device connected remotely? My issue is something similar to the one. My device is connected on a different server say 192.168.1.15. My tests are executed on a different server - 192.168.1.20. I have done port forwarding on 192.168.1.15 and when I call the statement AltRunUnityDriver, I give like this

AltrunUnityDriver(driver, platform=None,TCP_IP='192.168.1.15', TCP_PORT=13000, TCP_FORWARD_PORT=13000, requestEnd='#')

This doesn't work. I have to always copy the script to 192.168.1.15 to run the script. Is there a solution to this? cc: @ru.cindrea


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Can we give 0.0.0.0 instead of 127.0.0.1?


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

Hi @thejuskrishna! It is possible to run to a device remotely. Just change the IP address from AltSocketServer.cs to "0.0.0.0". Should look like this:

System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse("0.0.0.0");

After that you should be able to connect to the phone without doing port forwarding. Just make sure that you put the phone IP in tests.


You can find the original comment from GitLab here.

AltTesterBot commented 1 year ago

I am trying to automate iOS Unity Game App. Why is my below code throwing me SessionNotCreatedException ?

`@BeforeClass public static void setUp() throws IOException {

    DesiredCapabilities caps = new DesiredCapabilities();

    caps.setCapability("platformName", "iOS");
    caps.setCapability("deviceName", "CAREDeviPad");
    caps.setCapability("platformVersion", "12.4.9");
    caps.setCapability("udid", "DeviceUDID");
    caps.setCapability("automationName", "XCUITest");
    caps.setCapability("noReset", true);
    caps.setCapability("waitForQuiescence", false);

    File f = new File(System.getProperty("user.dir"));
    File fs = new File(f, "src/test/java/apps/AltUnityPoC.ipa");
    caps.setCapability("app", fs.getAbsolutePath());

    URL url = new URL("http://127.0.0.1:4723/wd/hub");

    driver = new AppiumDriver<MobileElement>(url, caps);

    AltUnityDriver.setupPortForwarding("iOS", "DeviceUDID", 13000, 13000);
    altdriver = new AltUnityDriver();
}`

Below is my log,

[RemoteTestNG] detected TestNG version 7.3.0 FAILED CONFIGURATION: @BeforeClass setUp org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Bad app: /Users/gsn/eclipse-workspace/MavenUnityProjectTest/src/test/java/apps/AltUnityPoC.ipa. App paths need to be absolute or an URL to a compressed app file: end of central directory record signature not found Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'Mac-mini.local', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.7', java.version: '14.0.2' Driver info: driver.version: AppiumDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Bad app: /Users/gsn/eclipse-workspace/MavenUnityProjectTest/src/test/java/apps/AltUnityPoC.ipa. App paths need to be absolute or an URL to a compressed app file: end of central directory record signature not found at getResponseForW3CError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9) at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:381:37) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'Mac-mini.local', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.7', java.version: '14.0.2' Driver info: driver.version: AppiumDriver at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:336) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:37) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:98) at samplePackage.testClass.setUp(testClass.java:54) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132) at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61) at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:366) at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:320) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.testng.TestRunner.privateRun(TestRunner.java:764) at org.testng.TestRunner.run(TestRunner.java:585) at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) at org.testng.SuiteRunner.run(SuiteRunner.java:286) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218) at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) at org.testng.TestNG.runSuites(TestNG.java:1069) at org.testng.TestNG.run(TestNG.java:1037) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:186) ... 38 more Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Bad app: /Users/gsn/eclipse-workspace/MavenUnityProjectTest/src/test/java/apps/AltUnityPoC.ipa. App paths need to be absolute or an URL to a compressed app file: end of central directory record signature not found Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'Mac-mini.local', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.7', java.version: '14.0.2' Driver info: driver.version: AppiumDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Bad app: /Users/gsn/eclipse-workspace/MavenUnityProjectTest/src/test/java/apps/AltUnityPoC.ipa. App paths need to be absolute or an URL to a compressed app file: end of central directory record signature not found at getResponseForW3CError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9) at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:381:37) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128) ... 43 more


You can find the original comment from GitLab here.