headspinio / appium-lg-webos-driver

An Appium 2.x driver for LG WebOS apps
Apache License 2.0
8 stars 4 forks source link

Not able to take screenshot of element #51

Open Jiyvn opened 3 months ago

Jiyvn commented 3 months ago

Issue

404 when taking screenshot of element

Mar 26, 2024 5:52:00 PM org.openqa.selenium.remote.ErrorCodes toStatus INFO: HTTP Status: '400' -> incorrect JSON status mapping for 'unknown error' (500 expected) When I launch viu app on LG TV # steps.lgTVDemoStepDef.LaunchViuOnLG() org.openqa.selenium.WebDriverException: Request failed with status code 404 Build info: version: '4.18.1', revision: 'b1d3319b48' System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.0', java.version: '17.0.7' Driver info: io.appium.java_client.AppiumDriver Command: [7be28ff2-6633-48b1-89b3-7551d8921b13, elementScreenshot {id=0.6263299632119397-1}] Capabilities {appium:app: /Users/jiyvn/aviu/apps/com...., appium:appId: com.viu.tv, appium:appLaunchCooldown: 3000, appium:autoExtendDevMode: true, appium:automationName: webos, appium:chromedriverExecutable: /Users/jiyvn/aviu/apps/tv/c..., appium:debuggerPort: 9998, appium:deviceHost: 192.168.10.186, appium:deviceInfo: {boardType: LM18A_DVB_EU, firmwareVersion: 05.50.15, modelName: 43UK6500PCC, otaId: HE_DTV_W18A_AFADABAA, sdkVersion: 4.4.0}, appium:deviceName: lg2018, appium:keyCooldown: 750, appium:noReset: false, appium:rcMode: js, appium:useSecureWebsocket: false, appium:websocketPort: 3000, appium:websocketPortSecure: 3001, platformName: lgtv} Element: [[AppiumDriver: on lgtv (7be28ff2-6633-48b1-89b3-7551d8921b13)] -> xpath: //button[@class="button-base medium button-contained MenuButton undefined"]] Session ID: 7be28ff2-6633-48b1-89b3-7551d8921b13 at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:237) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519) at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:223) at org.openqa.selenium.remote.RemoteWebElement.getScreenshotAs(RemoteWebElement.java:360) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.appium.java_client.pagefactory.ElementInterceptor.getObject(ElementInterceptor.java:42) at io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement.call(InterceptorOfASingleElement.java:79) at io.appium.java_client.proxy.Interceptor.intercept(Interceptor.java:78) at org.openqa.selenium.remote.RemoteWebElement$ByteBuddy$Ea7aYPfs.getScreenshotAs(Unknown Source)

code

BaseOptions options = new BaseOptions()
        .amend("appium:deviceName", "lg2018")
        .amend("platformName", "lgtv")
        .amend("appium:automationName", "webos")
        .amend("appium:deviceHost", "192.168.10.186")
        .amend("appium:noReset", false)
        .amend("appium:app", "/Users/jiyvn/aviu/apps/com.viu.tv_4.1.0_all.ipk")
        .amend("appium:appId", "com.viu.tv")
        .amend("appium:chromedriverExecutable","/Users/jiyvn/aviu/apps/tv/chromedriver/chromedriver_2.36")
        .amend("appium:rcMode", "js")   // or "rc"
        .amend("appium:useSecureWebsocket", false);
driver = new AppiumDriver(new URL("http://127.0.0.1:4723"), options);

tagetElement.getScreenshotAs(OutputType.BYTES)

logs

lg2018elementscreenshot.log

version

jlipps commented 3 months ago

The log shows an error where your client script is sending commands to a nonexisten session. Also, your code doesn't make sense: where is targetElement defined? Finally, I'm not sure Chromedriver 2.36 is new enough to support per element screenshots.

Jiyvn commented 3 months ago

@jlipps sorry, targetElement is a placeholder, actual locator is //button[@class="button-base medium button-contained MenuButton undefined"], and element id should be 0.6263299632119397-1 according to the error message provided above

jlipps commented 3 months ago

Sure, that's fine. My other two points remain relevant however.

Jiyvn commented 3 months ago

@jlipps tried chromedriver 2.37-2.46, unfortunately, no one can work. Can't even start session with 2.39~2.46