Closed bipin-k closed 1 year ago
@jlipps Can you please help me out with the above issue as reported and also, I was unable to figure out the solution for the below selective logs from above?
[Plugin [altunity]] Sending message 1679294925232 with command findObjects
[debug] [Plugin [altunity]] {"by":"PATH","path":"//*","cameraBy":"NAME","cameraPath":"//","enabled":true,"commandName":"findObjects","messageId":"1679294925232"}
[AppiumDriver@1597] Command 'getPageSource' was *not* handled by the following behaviours or plugins, even though they were registered to handle it: ["default"]. The command *was* handled by these: ["altunity","element-wait"].
[debug] [AndroidUiautomator2Driver@a4d7 (ef36be43)] Encountered internal error running command: Error: There is no websocket connection active
@jlipps I tried again with the app as provided with this repository, io.appium.unitysample/com.unity3d.player.UnityPlayerActivity' and still got the same issue as reported with appium
Appium v2.0.0-beta.57 (REV 9600617c52d0d2e48493424c529ac6c945d2775b)`,
Test Script Source Code
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class AltUnityTesterAppTest {
private AppiumDriver driver;
@BeforeMethod
public void setup() throws MalformedURLException {
DesiredCapabilities androidCaps = new DesiredCapabilities();
androidCaps.setCapability("appium:altUnityHost", "localhost");
androidCaps.setCapability("appium:altUnityPort", 13000);
androidCaps.setCapability("appium:appPackage", "io.appium.unitysample");
androidCaps.setCapability("appium:appActivity", "com.unity3d.player.UnityPlayerActivity");
androidCaps.setCapability("appium:automationName", "UIAutomator2");
androidCaps.setCapability("appium:platformName", "Android");
driver = new AndroidDriver(new URL("http://localhost:4723/"), androidCaps);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(600));
}
@Test
public void testApp() {
pause(10000);
System.out.println("Before Context --> " + ((AndroidDriver) driver).getContext());
((AndroidDriver) driver).context("UNITY");
pause(5000);
System.out.println("After Context --> " + ((AndroidDriver) driver).getContext());
pause(10000);
System.out.println(driver.getPageSource());
}
@AfterMethod
public void teardown() {
driver.quit();
}
public void pause(int duration) {
try {
TimeUnit.MILLISECONDS.sleep(duration);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
OUTPUT
Before Context --> NATIVE_APP
After Context --> UNITY
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: There is no websocket connection active
Build info: version: '4.8.1', revision: '8ebccac989'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.0.1', java.version: '17.0.4'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [88556ca3-f820-4245-bbc3-7ba01b769de8, getPageSource {}]
Appium Server Logs
--> GET /session/88556ca3-f820-4245-bbc3-7ba01b769de8/context
[HTTP] {}
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] Calling AppiumDriver.getCurrentContext() with args: ["88556ca3-f820-4245-bbc3-7ba01b769de8"]
[AppiumDriver@3c6e] Plugins which can handle cmd 'getCurrentContext': altunity,element-wait
[AppiumDriver@3c6e] Plugin element-wait is now handling cmd 'getCurrentContext'
[AppiumDriver@3c6e] Plugin altunity is now handling cmd 'getCurrentContext'
[AppiumDriver@3c6e] Command 'getCurrentContext' was *not* handled by the following behaviours or plugins, even though they were registered to handle it: ["default"]. The command *was* handled by these: ["altunity","element-wait"].
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] Responding to client with driver.getCurrentContext() result: "UNITY"
[HTTP] <-- GET /session/88556ca3-f820-4245-bbc3-7ba01b769de8/context 200 3 ms - 17
[HTTP]
[HTTP] --> GET /session/88556ca3-f820-4245-bbc3-7ba01b769de8/source
[HTTP] {}
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] Would have proxied command directly, but a plugin exists which might require its value, so will let its value be collected internally and made part of plugin chain
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] Calling AppiumDriver.getPageSource() with args: ["88556ca3-f820-4245-bbc3-7ba01b769de8"]
[AppiumDriver@3c6e] Plugins which can handle cmd 'getPageSource': altunity,element-wait
[AppiumDriver@3c6e] Plugin element-wait is now handling cmd 'getPageSource'
[AppiumDriver@3c6e] Plugin altunity is now handling cmd 'getPageSource'
[Plugin [altunity]] Sending message 1679311242077 with command findObjects
[debug] [Plugin [altunity]] {"by":"PATH","path":"//*","cameraBy":"NAME","cameraPath":"//","enabled":true,"commandName":"findObjects","messageId":"1679311242077"}
[AppiumDriver@3c6e] Command 'getPageSource' was *not* handled by the following behaviours or plugins, even though they were registered to handle it: ["default"]. The command *was* handled by these: ["altunity","element-wait"].
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] Encountered internal error running command: Error: There is no websocket connection active
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at /Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/client/connection.ts:223:27
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at new Promise (<anonymous>)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at Connection.sendMessage (/Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/client/connection.ts:220:22)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AltUnityClient._sendCommand (/Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/client/index.ts:159:43)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AltUnityClient.sendSimpleCommand (/Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/client/index.ts:171:34)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AltUnityClient.findObjects (/Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/client/commands/find.ts:21:28)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AltUnityClient.findAllObjects (/Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/client/commands/find.ts:32:23)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at /Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/commands/source.ts:39:42
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AltUnityPlugin.unityContextGuard (/Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/index.ts:144:22)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AltUnityPlugin.getPageSource (/Users/bipinchaurasia/node_modules/appium-altunity-plugin/src/commands/source.ts:38:23)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at /Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/lib/appium.js:735:35
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at WaitCommandPlugin.<anonymous> (/Users/bipinchaurasia/node_modules/appium-wait-plugin/lib/plugin.js:48:26)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at Generator.next (<anonymous>)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at /Users/bipinchaurasia/node_modules/appium-wait-plugin/lib/plugin.js:8:71
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at new Promise (<anonymous>)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at __awaiter (/Users/bipinchaurasia/node_modules/appium-wait-plugin/lib/plugin.js:4:12)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at WaitCommandPlugin.handle (/Users/bipinchaurasia/node_modules/appium-wait-plugin/lib/plugin.js:41:16)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at /Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/lib/appium.js:738:29
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AppiumDriver.executeWrappedCommand (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/lib/appium.js:775:22)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at AppiumDriver.executeCommand (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/lib/appium.js:697:28)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at asyncHandler (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:387:32)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at /Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:503:15
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at Layer.handle [as handle_request] (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at next (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/express/lib/router/route.js:144:13)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at Route.dispatch (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/express/lib/router/route.js:114:3)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at Layer.handle [as handle_request] (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at /Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:284:15
[debug] [AndroidUiautomator2Driver@a86d (88556ca3)] at param (/Users/bipinchaurasia/.nvm/versions/node/v16.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:365:14)
[HTTP] <-- GET /session/88556ca3-f820-4245-bbc3-7ba01b769de8/source 500 45 ms - 731
add a line to print out the call to driver.getContexts() before you switch to the unity context, and tell me what that says.
This issue is resolved and can be closed henceforth.
Unable to execute
driver.getPageSource()
while setting the driver context toUNITY
withAppium v2.0.0-beta.57
while running with plugins as,appium --use-plugins=altunity,relaxed-caps,element-wait --relaxed-security
.Also, I have forwarded the port to
13000
with adb command before running appium script as well,Following are the appium server logs,
What could be the issue with the appium script?