Issue Description along with Code:
protected WindowsDriver
java.lang.ClassCastException Issue if directly access the method like below:
System.out.print("Title Check: "+driver.findElementByAccessibilityId("Title).getText());
WorkAround: No java.lang.ClassCastException Issue if cast to the WebElement like below.
WebElement title = driver.findElementByAccessibilityId("Title");
getPrintHelper().print("Check the App Title: "+title.getText());
Environment:
Maven POM File:
Appium server version or git revision: WinAppDriver V1.0 release (File Version 1.0.1710.17001)
Desktop OS/version used to run Appium if necessary: Windows 10
Mobile platform/version under test: Windows 10 App
Note: Looks like same/similar issue as following:
https://github.com/Microsoft/WinAppDriver/issues/286
Exception stacktraces:
https://gist.github.com/aeroclee/b1d3bba03c3188d575b251b557c13cec
The workaround may work for reading/retrieving text, but it does not appear to work for writing/sending text (sendKeys).
Please make this a higher priority, as by my experience, it does not appear that there is a workaround for all situations.
Note: I am using the latest releases of all libraries noted above, except no TestNG. This includes java-client.
It seems we have not covered Winddows with tests. It is our fault I think. It is going to be fixed at the next BETA version.
@aeroclee Some questions/asking to make it clear
Are you automating native or web/hybrid application? may be desktop app?
Could you provide extanded sample to reproduce the issue and to check fixes?
Sergey,
Sorry if you saw the post previous to this a few minutes ago (I deleted it). It was for the wrong issue.
Unfortunately, I cannot share my code as it belongs to a client.
I finally did get my code to work however. https://github.com/notifications/beacon/AAjPaKyLqYXYkMMtN63IAbq720pu5p_kks5s8cGLgaJpZM4Qsckg.gif The problem is casting to a subclass (or better put, trying to cast a Superclass to a Subclass).
WindwosElement is derived from MobileElement, which is derived from RemoteWebElement.
If you write code like this:
WindowsElement title = driver.findElementByAccessibilityId("Title");
You are trying to cast a RemoteWebElement (which the right side returns, a Superclass) to one of its subclasses WindowsElement.
While the compiler trust you to do this, at runtime, it is caught, and the Exception we are discussing is thrown.
The workaround, appears to be the right way to handle it, though you would probably have access to more functionality if you utilize RemoteWebElement as I have done, as RemoteWebElement is a Class that Implements the WebElement interface.
As far as I can tell, this is the way the Java Client code has been architected (Functions As Designed).
The test cases for the Java Client never encounter this issue, as they never store a returned WebElement and utilize it, according to my sparse review.
So, when I declare my WindowsDriver, I do so like this WindowsDriver
One last interesting noteâŠ.driver.findElementsByAccessiblityId (note the plural findElements), returns a List
I hope this is helpful.
Thanks.
David
Can someone please help me. I am new to Appium, I have an Android App that I am trying to Automate.
My App that I am automating is a combination of Native and Web App. With the code that I have written I am able to open the App. Using UI Inspector I am able to locate elements as well. After running the code App opens up but Itâs unable to take user name and password
Hereâs my code with Appium logs and Selenium Webdriver Error:
package amazon;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
//import org.openqa.selenium.By;
//import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class AcceleratorLogin {
AndroidDriver> driver;
public void invokeLogin() {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/Apps/AcceleratorApp/");
File app = new File(appDir, "Accelerator_3.0Test_TimestampFix.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
//capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "Galaxt Tab E");
capabilities.setCapability("platformVersion", "7.1.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.navistar.writeup");
capabilities.setCapability("appActivity", "com.navistar.writeup.AcceleratorActivity");
try {
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Selenium Error:
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement cannot be cast to io.appium.java_client.MobileElement
at amazon.AcceleratorLogin.userLogin(AcceleratorLogin.java:45)
at amazon.AcceleratorLogin.main(AcceleratorLogin.java:57)
Appium Logs:
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[HTTP] --> POST /wd/hub/session {âdesiredCapabilitiesâ:{âappâ:âC:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apkâ,âappActivityâ:âcom.navistar.writeup.AcceleratorActivityâ,âappPackageâ:âcom.navistar.writeupâ,âautomationNameâ:âAppiumâ,âdeviceNameâ:âGalaxt Tab Eâ,âplatformNameâ:âAndroidâ,âplatformVersionâ:â7.1.1â},âcapabilitiesâ:{âdesiredCapabilitiesâ:{âappâ:âC:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apkâ,âappActivityâ:âcom.navistar.writeup.AcceleratorActivityâ,âappPackageâ:âcom.navistar.writeupâ,âautomationNameâ:âAppiumâ,âdeviceNameâ:âGalaxt Tab Eâ,âplatformNameâ:âAndroidâ,âplatformVersionâ:â7.1.1â},âfirstMatchâ:[{âplatformNameâ:âandroidâ}]}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{âappâ:âC:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apkâ,âappActivityâ:âcom.navistar.writeup.AcceleratorActivityâ,âappPackageâ:âcom.navistar.writeupâ,âautomationNameâ:âAppiumâ,âdeviceNameâ:âGalaxt Tab Eâ,âplatformNameâ:âAndroidâ,âplatformVersionâ:â7.1.1â},null,{âdesiredCapabilitiesâ:{âappâ:âC:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apkâ,âappActivityâ:âcom.navistar.writeup.AcceleratorActivityâ,âappPackageâ:âcom.navistar.writeupâ,âautomationNameâ:âAppiumâ,âdeviceNameâ:âGalaxt Tab Eâ,âplatformNameâ:âAndroidâ,âplatformVersionâ:â7.1.1â},âfirstMatchâ:[{âplatformNameâ:âandroidâ}]}]
[BaseDriver] Event ânewSessionRequestedâ logged at 1519320234628 (11:23:54 GMT-0600 (Central Standard Time))
[Appium] Merged W3C capabilities {âdesiredCapabilitiesâ:{âappâ:âC:\Users\u01n2⊠into desiredCapabilities object {âappâ:âC:\Users\u01n233\eclipse-workspace\âŠ
[Appium] Creating new AndroidDriver (v1.37.0) session
[Appium] Capabilities:
[Appium] app: C:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apk
[Appium] appActivity: com.navistar.writeup.AcceleratorActivity
[Appium] appPackage: com.navistar.writeup
[Appium] automationName: Appium
[Appium] deviceName: Galaxt Tab E
[Appium] platformName: android
[Appium] platformVersion: 7.1.1
[BaseDriver] Session created with session id: 1ab1bd8e-1899-466c-b9f0-2aeda35eab3f
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_151
[ADB] Checking whether adb is present
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android â7.1.1â
[ADB] Setting device id to fc591f301b82ddb5
[ADB] Getting device platform version
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: [â-Pâ,5037,"-s",âfc591f301b82ddb5â,âshellâ,âgetpropâ,âro.build.version.releaseâ]
[ADB] Current device property âro.build.version.releaseâ: 7.1.1
[AndroidDriver] Using device: fc591f301b82ddb5
[ADB] Checking whether adb is present
[ADB] Setting device id to fc591f301b82ddb5
[BaseDriver] Using local app âC:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apkâ
[AndroidDriver] Checking whether app is actually present
[AndroidDriver] Starting Android session
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âwait-for-deviceâ]
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âechoâ,âpingâ]
[AndroidDriver] setDeviceLanguageCountry requires language or country.
[AndroidDriver] Got language: âundefinedâ and country: âundefinedâ
[Logcat] Starting logcat capture
[AndroidDriver] Pushing settings apk to deviceâŠ
[ADB] Getting install status for io.appium.settings
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpmâ,âlistâ,âpackagesâ,âio.appium.settingsâ]
[ADB] App is installed
[ADB] Getting package info for io.appium.settings
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âdumpsysâ,âpackageâ,âio.appium.settingsâ]
[ADB] Checking whether aapt is present
[ADB] The installed âio.appium.settingsâ package does not require upgrade (5 >= 5)
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âgetpropâ,âro.build.version.sdkâ]
[ADB] Current device property âro.build.version.sdkâ: 25
[ADB] Device API level: 25
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âdumpsysâ,âpackageâ,âio.appium.settingsâ]
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpmâ,âdumpâ,âio.appium.settingsâ]
[ADB] Got the following command chunks to execute: pm,grant,io.appium.settings,android.permission.WRITE_SETTINGS,;,pm,grant,io.appium.settings,android.permission.ACCESS_MOCK_LOCATION,;
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpmâ,âgrantâ,âio.appium.settingsâ,âandroid.permission.WRITE_SETTINGSâ,";",âpmâ,âgrantâ,âio.appium.settingsâ,âandroid.permission.ACCESS_MOCK_LOCATIONâ,";"]
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpmâ,âgrantâ,âio.appium.settingsâ,âandroid.permission.WRITE_SETTINGSâ,";",âpmâ,âgrantâ,âio.appium.settingsâ,âandroid.permission.ACCESS_MOCK_LOCATIONâ,";"]
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpsâ]
[ADB] Device API level: 25
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âamâ,âstartâ,"-W","-n",âio.appium.settings/.Settingsâ,"-a",âandroid.intent.action.MAINâ,"-c",âandroid.intent.category.LAUNCHERâ,"-f",â0x10200000â]
[ADB] Device API level: 25
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âappopsâ,âsetâ,âio.appium.settingsâ,âandroid:mock_locationâ,âallowâ]
[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 âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,â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 âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âdumpsysâ,âpackageâ,âio.appium.unlockâ]
[ADB] Checking whether aapt is present
[ADB] The installed âio.appium.unlockâ package does not require upgrade (2 >= 2)
[ADB] Getting device platform version
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âgetpropâ,âro.build.version.releaseâ]
[ADB] Current device property âro.build.version.releaseâ: 7.1.1
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âwmâ,âsizeâ]
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âgetpropâ,âro.product.modelâ]
[ADB] Current device property âro.product.modelâ: SM-T560NU
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âgetpropâ,âro.product.manufacturerâ]
[ADB] Current device property âro.product.manufacturerâ: samsung
[AndroidDriver] Remote apk path is /data/local/tmp/1ae3bbafefcb152e97400c52646c1329.apk
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âlsâ,"/data/local/tmp/1ae3bbafefcb152e97400c52646c1329.apk"]
[AndroidDriver] Checking if app is installed
[ADB] Getting install status for com.navistar.writeup
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpmâ,âlistâ,âpackagesâ,âcom.navistar.writeupâ]
[ADB] App is installed
[AndroidDriver] Apk is already on remote and installed, resetting
[AndroidDriver] Running fast reset (stop and clear)
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âamâ,âforce-stopâ,âcom.navistar.writeupâ]
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpmâ,âclearâ,âcom.navistar.writeupâ]
[AndroidDriver] Extracting strings from apk C:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apk undefined C:\Users\u01n233\AppData\Local\Temp\com.navistar.writeup
[ADB] Extracting strings for language: default
[ADB] Device API level: 25
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âgetpropâ,âpersist.sys.localeâ]
[ADB] Current device property âpersist.sys.localeâ: en-US
[ADB] No strings.xml for language âenâ, getting default strings.xml
[ADB] Reading strings from converted strings.json
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âpushâ,âC:\Users\u01n233\AppData\Local\Temp\com.navistar.writeup\strings.jsonâ,"/data/local/tmp"]
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,â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 âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âpushâ,âC:\Users\u01n233\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\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 âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âpsâ]
[ADB] Attempting to kill process 18784
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âkillâ,"-0",18784]
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âkillâ,18784]
[UiAutomator] UiAutomator exited unexpectedly with code 4294967183, signal null
[UiAutomator] Moving to state âstoppedâ
[AndroidDriver] Shutting down Android driver
[Appium] Closing session, cause was âUiAUtomator shut down unexpectedlyâ
[Appium] Removing session 585a649e-f01a-4d9f-8298-896f473fb0b6 from our master session list
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âamâ,âforce-stopâ,âcom.navistar.writeupâ]
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âkillâ,18784]
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âkillâ,18784]
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âuiautomatorâ,âruntestâ,âAppiumBootstrap.jarâ,"-c",âio.appium.android.bootstrap.Bootstrapâ,"-e",âpkgâ,âcom.navistar.writeupâ,"-e",âdisableAndroidWatchersâ,false,"-e",âacceptSslCertsâ,false]
[ADB] Pressing the HOME button
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âinputâ,âkeyeventâ,3]
[UiAutomator] Moving to state âonlineâ
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] json loading complete.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Getting connected devicesâŠ
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âdumpsysâ,âwindowâ]
[AndroidBootstrap] Cannot shut down Android bootstrap; it has already shut down
[Logcat] Stopping logcat capture
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âamâ,âforce-stopâ,âio.appium.unlockâ]
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Device API level: 25
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âamâ,âstartâ,"-W","-n",âcom.navistar.writeup/com.navistar.writeup.AcceleratorActivityâ,"-S"]
[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
[Appium] New AndroidDriver session created successfully, session 1ab1bd8e-1899-466c-b9f0-2aeda35eab3f added to master session list
[BaseDriver] Event ânewSessionStartedâ logged at 1519320276629 (11:24:36 GMT-0600 (Central Standard Time))
[MJSONWP] Responding to client with driver.createSession() result: {âplatformâ:âLINUXâ,âwebStorageEnabledâ:false,âtakesScreenshotâ:true,âjavascriptEnabledâ:true,âdatabaseEnabledâ:false,ânetworkConnectionEnabledâ:true,âlocationContextEnabledâ:false,âwarningsâ:{},âdesiredâ:{âappâ:âC:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apkâ,âappActivityâ:âcom.navistar.writeup.AcceleratorActivityâ,âappPackageâ:âcom.navistar.writeupâ,âautomationNameâ:âAppiumâ,âdeviceNameâ:âGalaxt Tab Eâ,âplatformNameâ:âandroidâ,âplatformVersionâ:â7.1.1â},âappâ:âC:\Users\u01n233\eclipse-workspace\AppiumTestProject\Apps\AcceleratorApp\Accelerator_3.0Test_TimestampFix.apkâ,âappActivityâ:âcom.navistar.writeup.AcceleratorActivityâ,âappPackageâ:âcom.navistar.writeupâ,âautomationNameâ:âAppiumâ,âdeviceNameâ:âfc591f301b82ddb5â,âplatformNameâ:âandroidâ,âplatformVersionâ:â7.1.1â,âdeviceUDIDâ:âfc591f301b82ddb5â,âdeviceScreenSizeâ:â800x1280â,âdeviceModelâ:âSM-T560NUâ,âdeviceManufacturerâ:âsamsungâ}
[HTTP] <-- POST /wd/hub/session 200 41999 ms - 1048
[HTTP] --> POST /wd/hub/session/1ab1bd8e-1899-466c-b9f0-2aeda35eab3f/element {âusingâ:âidâ,âvalueâ:âusernameâ}
[MJSONWP] Calling AppiumDriver.findElement() with args: [âidâ,âusernameâ,â1ab1bd8e-1899-466c-b9f0-2aeda35eab3fâ]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[AndroidBootstrap] Sending command to android: {âcmdâ:âactionâ,âactionâ:âfindâ,âparamsâ:{âstrategyâ:âidâ,âselectorâ:âusernameâ,âcontextâ:"",âmultipleâ:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {âcmdâ:âactionâ,âactionâ:âfindâ,âparamsâ:{âstrategyâ:âidâ,âselectorâ:âusernameâ,âcontextâ:"",âmultipleâ:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding âusernameâ using âIDâ with the contextId: ââ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.navistar.writeup:id/username]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=android:id/username]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=username]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {âstatusâ:0,âvalueâ:{âELEMENTâ:â1â}}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.findElement() result: {âELEMENTâ:â1â}
[HTTP] <-- POST /wd/hub/session/1ab1bd8e-1899-466c-b9f0-2aeda35eab3f/element 200 30459 ms - 87
[BaseDriver] Shutting down because we waited 60 seconds for a command
[AndroidDriver] Shutting down Android driver
[Appium] Closing session, cause was âNew Command Timeout of 60 seconds expired. Try customizing the timeout using the ânewCommandTimeoutâ desired capabilityâ
[Appium] Removing session 1ab1bd8e-1899-466c-b9f0-2aeda35eab3f from our master session list
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âamâ,âforce-stopâ,âcom.navistar.writeupâ]
[ADB] Pressing the HOME button
[ADB] Getting connected devicesâŠ
[ADB] 1 device(s) connected
[ADB] Running âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,â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: {âstatusâ:0,âvalueâ:âOK, shutting downâ}
[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 âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,â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 âC:\Android\android-sdk\platform-tools\adb.exeâ with args: ["-P",5037,"-s",âfc591f301b82ddb5â,âshellâ,âamâ,âforce-stopâ,âio.appium.unlockâ]
[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
Appium server stopped successfully
Yes
im getting below issue
How to resolve the issue
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement cannot be cast to io.appium.java_client.MobileElement
at com.zenq.demo.AppTest.main(AppTest.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:571)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.runSuites(TestNG.java:1028)
at org.testng.TestNG.run(TestNG.java:996)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
//Code is Here
@Test
public void main() {
try
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "Android");
capabilities.setCapability("deviceName", "Nexus 5 ");
capabilities.setCapability("udid", "077c35ee0ade546b");
capabilities.setCapability("platformName", "Android");
// You need to have this sdk installed for Appium to work
capabilities.setCapability("platformVersion", "5.1.1");
capabilities.setCapability("appPackage", "net.one97.paytm");
capabilities.setCapability("appActivity", "net.one97.paytm.landingpage.activity.AJRMainActivity");
//capabilities.setCapability("apkFile", apkFile.getAbsolutePath());
capabilities.setCapability("autoGrantPermissions","true");
URL url=new URL("http://0.0.0.0:4723/wd/hub");
// RemoteWebDriver driver= new RemoteWebDriver(url, capabilities);
AndroidDriver<MobileElement> androidDriver=new AndroidDriver<MobileElement>(url,capabilities);
//RemoteWebDriver driver=androidDriver;
System.out.println(androidDriver.toString());
//Here im getting cast exception
androidDriver.findElement(By.id("net.one97.paytm:id/btn_language_continue_button")).click();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Even I'm facing the same issue i.e io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
capabilities.setCapability(MobileCapabilityType.VERSION, Config.get("MobileCapabilityType.VERSION"));
capabilities.setCapability("appPackage", Config.get("appPackage"));
capabilities.setCapability("appActivity", Config.get("appActivity"));
capabilities.setCapability(MobileCapabilityType.APP, Config.get("apkPath"));
URL url = new URL("http://127.0.0.1:4723/wd/hub");
mdriver = new AndroidDriver
public static void singleTap(AppiumDriver
try {
TouchActions action = new TouchActions(mdriver);
action.singleTap(mdriver.findElement(locator));
action.perform();
Assert.assertTrue(true);
} catch (Exception e) {
Assert.fail("The element : " + locator + " is not visibile/not enabled - '"
+ "' and the error message is " + e.getMessage());
}
}
Mobile.singleTap(mdriver, By.id("io.selendroid.testapp:id/buttonTest"));
Error : java.lang.AssertionError: The element : By.id: io.selendroid.testapp:id/buttonTest is not visibile/not enabled and the error message is io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen.
Please help me.
Download and add the below jar file into your Project @Vidya Sagar Pogiri
selenium-api/selenium-api-2.26.0.jar.zip( 117 k)
I have this issue in Windows/C# when finding by id. Very annoying
I have the same issue (Invalid Cast Exception) when using C# on Windows to automate an iOS app running in a simulator on a Mac. The exception happens when running the following code after declaring the IOSDriver< IOSElement >: IWebElement result = this.Driver.FindElement(strategy);. "this.Driver" is an IWebDriver reference to the IOSDriver < IOSElement >. The Workaround as discussed above is to declare the driver this way: IOSDriver < RemoteWebElement >. But, I'm sure I'm going to run into issues on the FindElements code. Our automation code works across iOS, Windows, and Android via fairly generic automation tests written in C#. I hope things like this will be fixed!
Dear Sir:
I also have the same problem.
I can not use AndroidDriver.
I can only use RemoteWebDriver.
Code:
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.MobileBy;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class ScorllBar {
private static RemoteWebDriver driver =null;
private static AndroidDriver androidDriver=null;
public static void main(String[] args) throws MalformedURLException, Exception {
// TODO Auto-generated method stub
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("platformName", "Android");
cap.setCapability("platformVersion", 5);
cap.setCapability("deviceName", "Android Emulator");
cap.setCapability("automationName", "Appium");
cap.setCapability("appPackage", "tw.com.wgh3h");
cap.setCapability("appActivity", "tw.com.demo1.MyMainPage");
//RemoteWebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
AndroidDriver androidDriver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);
driver = androidDriver;
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
ErrorMessage:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/websocket/DeploymentException
at io.appium.java_client.android.ListensToLogcatMessages.
at ScorllBar.main(ScorllBar.java:32)
Caused by: java.lang.ClassNotFoundException: javax.websocket.DeploymentException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Test environment:
Java Client:java-client-6.0.0
Appium:1.8.1
Eclipse:Oxygen.3a Release (4.7.3a)
how to switch native to webview am not able to do in iOS app, getting below error whenever i tried using above code
@ronjonesjr @dpgraham @sbonebrake @mykola-mokhnach @imurchie please help
AppiumDriver
at io.appium.java_client.AppiumDriver.getContextHandles(AppiumDriver.java:227)
at ZDebugTests.iOSTest.main(iOSTest.java:28)
Caused by: java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to java.util.List
at io.appium.java_client.AppiumDriver.getContextHandlesï»ż
same issue with
TouchActions action = new TouchActions(driver);
action.scroll(fwutils.CheckElement(driver, path_video_label, "xpath"), 100, 100);
action.perform();
fwutils is:
`public MobileElement CheckElement(AppiumDriver driver, String path, String option) throws Exception
{
MobileElement element = null;
switch (option)
{
case "xpath":
element = (MobileElement) driver.findElementByXPath(path);
break;
case "id":
element = (MobileElement) driver.findElementById(path);
break;
case "access_id":
element = (MobileElement) driver.findElementByAccessibilityId(path);
break;
}
if (element == null)
{
throw new Exception(path + " not found");
}
return (element);
}`
getting:
Exception: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreenjava.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
is that beta version really coming? a year has passed
Hey, I'm having the same issues with my java client binding verison 7.0.0 with using appium. I get the same "cannot be cast" error and I'm not able to send any text to a field in my desktop application for my automation. Any updates on this issue?
Most helpful comment
Sergey,
Sorry if you saw the post previous to this a few minutes ago (I deleted it). It was for the wrong issue.
Unfortunately, I cannot share my code as it belongs to a client.
I finally did get my code to work however. https://github.com/notifications/beacon/AAjPaKyLqYXYkMMtN63IAbq720pu5p_kks5s8cGLgaJpZM4Qsckg.gif The problem is casting to a subclass (or better put, trying to cast a Superclass to a Subclass).
WindwosElement is derived from MobileElement, which is derived from RemoteWebElement.
If you write code like this:
WindowsElement title = driver.findElementByAccessibilityId("Title");
You are trying to cast a RemoteWebElement (which the right side returns, a Superclass) to one of its subclasses WindowsElement.
While the compiler trust you to do this, at runtime, it is caught, and the Exception we are discussing is thrown.
The workaround, appears to be the right way to handle it, though you would probably have access to more functionality if you utilize RemoteWebElement as I have done, as RemoteWebElement is a Class that Implements the WebElement interface.
As far as I can tell, this is the way the Java Client code has been architected (Functions As Designed).
The test cases for the Java Client never encounter this issue, as they never store a returned WebElement and utilize it, according to my sparse review.
So, when I declare my WindowsDriver, I do so like this WindowsDriver instead of WindowsDriver as instructed.
One last interesting noteâŠ.driver.findElementsByAccessiblityId (note the plural findElements), returns a List and you must declare your variable this way. However, as you iterate over that list and inspect the list for what you are looking for, you must use a RemoteWebElement variable, and essentially down cast it.
I hope this is helpful.
Thanks.
David