diff --git a/Assets/AltTester/Runtime/AltDriver/Communication/DriverWebSocketClient.cs b/Assets/AltTester/Runtime/AltDriver/Communication/DriverWebSocketClient.cs index 21486f4ac..7cc1b1261 100644 --- a/Assets/AltTester/Runtime/AltDriver/Communication/DriverWebSocketClient.cs +++ b/Assets/AltTester/Runtime/AltDriver/Communication/DriverWebSocketClient.cs @@ -138,6 +138,7 @@ public void Connect() string proxyUri = new ProxyFinder().GetProxy(string.Format("http://{0}:{1}", this.host, this.port), this.host); if (proxyUri != null) { + logger.Info("Using proxy in DriverWebSocketClient: '{0}'.", proxyUri); wsClient.SetProxy(proxyUri, null, null); } diff --git a/Assets/AltTester/Runtime/AltDriver/Proxy/AndroidProxyFinder.cs b/Assets/AltTester/Runtime/AltDriver/Proxy/AndroidProxyFinder.cs index 0436ca6e4..86ec8bdca 100644 --- a/Assets/AltTester/Runtime/AltDriver/Proxy/AndroidProxyFinder.cs +++ b/Assets/AltTester/Runtime/AltDriver/Proxy/AndroidProxyFinder.cs @@ -18,18 +18,23 @@ You should have received a copy of the GNU General Public License #if !UNITY_EDITOR && UNITY_ANDROID using System; using UnityEngine; +using AltTester.AltTesterSDK.Driver.Logging; namespace AltTester.AltTesterSDK.Driver.Proxy { public class AndroidProxyFinder : IProxyFinder { + private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger(); + public string GetProxy(string uri, string host) { + logger.Info("AndroidProxyFinder.GetProxy called with uri: {0}, host: {1}", uri, host); return CallJavaGetProxy(uri); } private string CallJavaGetProxy(string uri) { + logger.Info("Calling Java method to get proxy for uri in AndroidProxyFinder: {0}", uri); using (var JavaClass = new AndroidJavaClass("com.alttester.utils.AltProxyFinder")) { return JavaClass.CallStatic("getProxy", uri); } diff --git a/Assets/AltTester/Runtime/AltDriver/Proxy/DotnetProxyFinder.cs b/Assets/AltTester/Runtime/AltDriver/Proxy/DotnetProxyFinder.cs index dc5a9730b..a792f3631 100644 --- a/Assets/AltTester/Runtime/AltDriver/Proxy/DotnetProxyFinder.cs +++ b/Assets/AltTester/Runtime/AltDriver/Proxy/DotnetProxyFinder.cs @@ -16,13 +16,17 @@ You should have received a copy of the GNU General Public License */ using System; +using AltWebSocketSharp; +using AltTester.AltTesterSDK.Driver.Logging; namespace AltTester.AltTesterSDK.Driver.Proxy { public class DotnetProxyFinder : IProxyFinder { + private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger(); public string GetProxy(string uri, string host) { + logger.Info("DotnetProxyFinder.GetProxy called with uri: {0}, host: {1}", uri, host); var Proxy = System.Net.WebRequest.GetSystemWebProxy() as System.Net.WebProxy; if (Proxy != null && Proxy.Address != null) { @@ -33,7 +37,7 @@ public string GetProxy(string uri, string host) return proxyUri; } } - + logger.Info("No proxy found for in DotnetProxyFinder uri: {0} and host: {1}", uri, host); return null; } } diff --git a/Assets/AltTester/Runtime/AltDriver/Proxy/EnvironmentProxyFinder.cs b/Assets/AltTester/Runtime/AltDriver/Proxy/EnvironmentProxyFinder.cs index 3d9106482..337003be1 100644 --- a/Assets/AltTester/Runtime/AltDriver/Proxy/EnvironmentProxyFinder.cs +++ b/Assets/AltTester/Runtime/AltDriver/Proxy/EnvironmentProxyFinder.cs @@ -17,11 +17,13 @@ You should have received a copy of the GNU General Public License using System; using System.Linq; +using AltTester.AltTesterSDK.Driver.Logging; namespace AltTester.AltTesterSDK.Driver.Proxy { public class EnvironmentProxyFinder : IProxyFinder { + private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger(); public string GetProxy(string uri, string host) { // TODO: Check HTTPS_PROXY if we use wss @@ -38,15 +40,17 @@ public string GetProxy(string uri, string host) if (!string.IsNullOrEmpty(exceptions)) { + logger.Info("NO_PROXY environment variable found in EnvironmentProxyFinder: {0}", exceptions); var exceptionsList = exceptions.Split(';').ToList(); if (exceptionsList.Contains(proxyUrl)) { + logger.Info("Proxy {0} is in NO_PROXY list, skipping in EnvironmentProxyFinder.", proxyUrl); return null; } } } - + logger.Info("Using proxy in EnvironmentProxyFinder: {0} for uri: {1} and host: {2}", proxyUrl, uri, host); return proxyUrl; } diff --git a/Assets/AltTester/Runtime/AltDriver/Proxy/IOSProxyFinder.cs b/Assets/AltTester/Runtime/AltDriver/Proxy/IOSProxyFinder.cs index 7b827e276..fa061960a 100644 --- a/Assets/AltTester/Runtime/AltDriver/Proxy/IOSProxyFinder.cs +++ b/Assets/AltTester/Runtime/AltDriver/Proxy/IOSProxyFinder.cs @@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License using System.Runtime.InteropServices; using System.Globalization; using UnityEngine; +using AltTester.AltTesterSDK.Driver.Logging; namespace AltTester.AltTesterSDK.Driver.Proxy { @@ -28,15 +29,18 @@ public class IOSProxyFinder : IProxyFinder [DllImport("__Internal")] private static extern string _getProxy(string uri, string host); + private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger(); + public string GetProxy(string uri, string host) { var result = _getProxy(uri, host); if (string.IsNullOrEmpty(result)) { + logger.Info("No proxy found in IOSProxyFinder for uri: {0} and host: {1}", uri, host); return null; } - + logger.Info("Using proxy in IOSProxyFinder: {0} for uri: {1} and host: {2}", result, uri, host); return result; } } diff --git a/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinder.swift b/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinder.swift index 283909e9d..0f23d3651 100644 --- a/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinder.swift +++ b/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinder.swift @@ -2,6 +2,7 @@ import Foundation import JavaScriptCore @objc public class AltProxyFinder: NSObject { + @objc public static let shared = AltProxyFinder() @objc public func swiftGetProxy(_ destinationUrl: String, destinationHost: String) -> String { @@ -31,8 +32,10 @@ import JavaScriptCore // Workaround for BrowserStack with Forced Local mode. // An issue arises where, instead of receiving the expected PAC file, an error page is returned, // parsing which would lead to a crash in the application. + NSLog("PAC content") pacContent = pacContent.trimmingCharacters(in: .whitespacesAndNewlines) if (pacContent.starts(with:"")) { + NSLog("Received an error page instead of PAC file. Please check the PAC URL: \(pacUrl)") return } @@ -48,19 +51,20 @@ import JavaScriptCore if (host == "null" || port == 0) { return } - + NSLog("PAC Proxy Host: \(host), Port: \(port)") proxyUrl = "http://" + host + ":" + String(port) } } } } else if let error = error { // Handle Error + NSLog("Error fetching PAC file: \(error.localizedDescription)") } } task.resume() semaphore.wait() - + NSLog("PAC Proxy URL: \(proxyUrl)") return proxyUrl } @@ -68,6 +72,7 @@ import JavaScriptCore destinationUrl.starts(with: "https") { if let host = systemProxySettings["HTTPSProxy"] as? String, let port = systemProxySettings["HTTPSPort"] as? Int { + NSLog("HTTPS Proxy Host in AltProxyFinder: \(host), Port: \(port)") return "https://\(host):\(port)" } } @@ -75,10 +80,11 @@ import JavaScriptCore if let httpEnable = systemProxySettings["HTTPEnable"] as? Int, httpEnable == 1 { if let host = systemProxySettings["HTTPProxy"] as? String, let port = systemProxySettings["HTTPPort"] as? Int { + NSLog("HTTP Proxy Host in AltProxyFinder: \(host), Port: \(port)") return "http://\(host):\(port)" } } - + NSLog("No proxy found for the given URL in AltProxyFinder: \(destinationUrl)") return "" } } diff --git a/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinderBridge.mm b/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinderBridge.mm index b7b036eb9..52ed9c5e2 100644 --- a/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinderBridge.mm +++ b/Assets/AltTester/Runtime/AltDriver/Proxy/Plugins/iOS/AltProxyFinder/Source/AltProxyFinderBridge.mm @@ -16,6 +16,7 @@ char* _getProxy(const char* uri, const char* host) { NSString *returnString = [[AltProxyFinder shared] swiftGetProxy:[NSString stringWithUTF8String:uri] destinationHost:[NSString stringWithUTF8String:host]]; + NSLog(@"_getProxy: uri: %s, host: %s, returnString: %@", uri, host, returnString); return cStringCopy([returnString UTF8String]); } } diff --git a/Assets/AltTester/Runtime/AltDriver/Proxy/ProxyFinder.cs b/Assets/AltTester/Runtime/AltDriver/Proxy/ProxyFinder.cs index a25112594..1fc0c55a3 100644 --- a/Assets/AltTester/Runtime/AltDriver/Proxy/ProxyFinder.cs +++ b/Assets/AltTester/Runtime/AltDriver/Proxy/ProxyFinder.cs @@ -16,11 +16,13 @@ You should have received a copy of the GNU General Public License */ using System; +using AltTester.AltTesterSDK.Driver.Logging; namespace AltTester.AltTesterSDK.Driver.Proxy { public class ProxyFinder : IProxyFinder { + private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger(); public string GetProxy(string uri, string host) { #if !UNITY_EDITOR && UNITY_WEBGL @@ -39,6 +41,7 @@ public string GetProxy(string uri, string host) } catch (Exception) { + logger.Info("AndroidProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host); } #endif @@ -50,9 +53,9 @@ public string GetProxy(string uri, string host) } catch (Exception) { + logger.Info("IOSProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host); } #endif - if (ProxyUri == null) { try @@ -62,6 +65,7 @@ public string GetProxy(string uri, string host) } catch (Exception) { + logger.Info("EnvironmentProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host); } } @@ -74,9 +78,10 @@ public string GetProxy(string uri, string host) } catch (Exception) { + logger.Info("DotnetProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host); } } - + logger.Info("Using proxy in ProxyFinder: {0} for uri: {1} and host: {2}", ProxyUri, uri, host); return ProxyUri; } } diff --git a/Assets/AltTester/Runtime/Communication/RuntimeWebSocketClient.cs b/Assets/AltTester/Runtime/Communication/RuntimeWebSocketClient.cs index 184e1a27b..288fafba9 100644 --- a/Assets/AltTester/Runtime/Communication/RuntimeWebSocketClient.cs +++ b/Assets/AltTester/Runtime/Communication/RuntimeWebSocketClient.cs @@ -29,7 +29,7 @@ namespace AltTester.AltTesterUnitySDK.Communication public class RuntimeWebSocketClient : IRuntimeWebSocketClient { private ClientWebSocket wsClient; - + private static readonly NLog.Logger logger = ServerLogManager.Instance.GetCurrentClassLogger(); private readonly string host; private readonly int port; private readonly string appName; @@ -69,6 +69,7 @@ public RuntimeWebSocketClient(string host, int port, string path, string appName string proxyUri = new ProxyFinder().GetProxy(string.Format("http://{0}:{1}", host, port), host); if (proxyUri != null) { + logger.Info("Using proxy in RuntimeWebSocketClient: {0} for uri: {1} and host: {2}", proxyUri, uri, host); wsClient.SetProxy(proxyUri, null, null); } diff --git a/Assets/AltTester/Runtime/UI/AltDialog.cs b/Assets/AltTester/Runtime/UI/AltDialog.cs index 48cd2bc34..4d2cc1051 100644 --- a/Assets/AltTester/Runtime/UI/AltDialog.cs +++ b/Assets/AltTester/Runtime/UI/AltDialog.cs @@ -712,6 +712,7 @@ public static async Task Get(string url) using (var client = new HttpClient()) { client.Timeout = TimeSpan.FromMilliseconds(50000); + logger.Info("Sending GET from AltDialog request to: " + url); return await client.GetAsync(url); } } diff --git a/Bindings~/python/tests/integration/conftest.py b/Bindings~/python/tests/integration/conftest.py index 998742327..915a79b42 100644 --- a/Bindings~/python/tests/integration/conftest.py +++ b/Bindings~/python/tests/integration/conftest.py @@ -101,7 +101,8 @@ def alt_driver(request, appium_driver, worker_id, current_device): app_name=get_app_name(), platform=platform, platform_version=current_device["os_version"].split(".")[0], - timeout=180 + timeout=180, + enable_logging=True ) if alt_driver is None: raise RuntimeError(