Appium Beginner Tutorial 7 | First Appium Project with Java
Вставка
- Опубліковано 5 тра 2019
- FREE Courses - automationstepbystep.com/
Check Troubleshooting tips below
Steps
1. Download & Open IDE
2. Create Java Project
3. Add selenium & appium libraries
4. Connect mobile device
5. Start appium server
6. Write code to start a mobile application
7. Use appium desktop client to find element locators
Step 1: Download Eclipse or any other IDE for Java
• Java
Step 2 : Create a Java project
Step 3 : Add libraries
Selenium java
Appium java client
mvnrepository.com/
Step 4 : Connect device
run command : adb devices
Step 5 : Start appium server
can do from command line or appium desktop client
Step 6 : Add code to start automation on mobile device
Set desired capabilities
deviceName
udid
platformName
platformVersion
appPackage
appActivity
127.0.0.1:4723/wd/hub
Start calculator application
Step 7 : Run and validate
Troubleshooting tips
(contributed by Flavius-Cristian Luca)
- Issues with getting io.appium.uiautomator2.server.test package info: github.com/appium/appium-uiau...
- Original error: 'app' option is required for reinstall: for this, i added the following line of code
desiredCapabilities.setCapability(MobileCapabilityType.APP, "C:\\Users\\<<userName>\\AppData\\Roaming\
pm\
ode_modules\\appium\
ode_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v4.8.3.apk" );
-Error executing adbExec. on Android(M): github.com/appium/appium/issu...
#AppiumBeginnerTutorials
Udemy - www.udemy.com/user/raghav-pal-3/
Training schedule - automationstepbystep.com/trai...
----------- UI TESTING -----------
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework with RIDE- bit.ly/2Px6Ue9
Robot Framework with Eclipse - bit.ly/2N8DZxb
----------- API TESTING -----------
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
General - bit.ly/2PYdwmV
Katalon Studio API Testing - bit.ly/2BwuCTN
----------- MOBILE TESTING -----------
Appium - tinyurl.com/y3c8ckz8
Mobile Playlist - bit.ly/2PxpeUv
----------- CI | CD | DEVOPS -----------
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
----------- VERSION CONTROL SYSTEM -----------
Git & GitHub - bit.ly/2Q1pagY
----------- PERFORMANCE TESTING -----------
JMeter Beginner - bit.ly/2oBbtIU
JMeter Intermediate - bit.ly/2oziNVB
JMeter Advanced - bit.ly/2Q22Y6a
JMeter Tips & Tricks - bit.ly/2NOfWD2
Performance Testing - bit.ly/2wEXbLS
----------- PROGRAMMING -----------
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
GROOVY - bit.ly/2FvWV5C
----------- IDE -----------
Visual Studio Code - bit.ly/2V15yvt
----------- MAVEN -----------
Maven - bit.ly/2NJdDRS
----------- OTHERS -----------
Redis- bit.ly/2N9jyCG
Misc - bit.ly/2Q2q5xQ
Tools & Tips - bit.ly/2oBfwoR
QnA Friday- bit.ly/2NgwGpw
Sunday Special - bit.ly/2wB23BO
Ask Raghav - bit.ly/2CoJGWf
Interviews - bit.ly/2NIPPxk
All Playlists - bit.ly/2LSiezA
Never Stop Learning,
Raghav
You can support my mission for education by sharing this knowledge and helping as many people as you can
Thank you so much for such clear explanation! All magic from Appium docs went away
You're welcome Riario
I'm a beginner at this and thus far I'm really enjoying your tutorials, thanks for making it so easy to grasp.
Most welcome Debra
Great job, Raghav, as a total beginner, I was able to install Appium, connect a device and open the calculator on it. Feels like ordering a pizza on the phone in Welsh and having it delivered successfully to my doorstep. Great of you to think of us beginners!
Great to know, All the best
Hi, I've been watching your videos. You're doing a great job. I've been in automation from years but every now and then need a refresher of basics, your videos come in handy. Thanks for your hard work.
So happy to know this Manish. Keep learning.
I wanted to thank you Raghav, your videos are really helping me a lot. God bless you!
You're welcome Steve
@@RaghavPal if we have a multiple app activities then how we can get exact app activity for a application
you really deserve millions of subscribers brother,great job ,keep it up !
Thanks a lot for the wishes Shobhit
Thank you for this tutorial! I leaned a lot of things and you explained it perfectly! You are the best!
Thanks a lot for your message Peter. Humbled
Today is Teacher's Day 5th September and I want to really thank you for the wonderful service. Hatsoff to you. I've been referring your videos for learning Appium and its crystal clear🙂
Thanks a lot Jyothi
A simple approach to start mobile testing, thank you.
You're welcome Bharadwaj
Your tutorial videos are incredibly useful and easy to follow. Thank you very much!
You're very welcome Andrés
Thanks. Great video. Great explanation. Helps alot to understand. Big thanks. U rock
You're welcome Rashmi
Hello Ragav,
You are such a great teacher...in words can't describe your way of teaching style and updating the series properly .... I am so happy after seeing this video I learnt api and appium automation it's bcz of only you..your videos are awesome and it's really helpful.. thank you so much...
You are most welcome Saranya
Really want to thanks you very much as i spent a lot of time to perform this. Just due to finally succeed.
You're most welcome Himanshu
Thank you soo much Raghav!!!😊😊😊 For clear Explanation
You're welcome Anand
Thank you so much for the detail explanation and video. I am very new to Mobile automation and your videos are very helpful for me to stepup further. Thanks alot for sharing detailed videos
Most welcome
Great stuff. very clear and easy to follow. Good job bro!
Glad you liked it Hao
and the real project begins 😊 wooohoo
Thanks for watching Sarang
best tutorial ever, thank you very much for making it so easy to learn
You're very welcome Dasra
Thank you so much, I solved by using wait options
Happy to know this Evangelin
By far this is the best tutorial I have watched for appiuum Thank you.
You are most welcome Deepak
Sir, you did a great job on this tutorial. Please upload more tutorials on how to do the application testing on real device.
Sure Srividya, will do
Amazing tutorials!! Thank you very much 🙏
Most welcome
Raghav Sir , you are a Genius , your videos makes me understand the concept very well .
So happy and humble to know this Garima
@@RaghavPal i am getting error MobileElement cannot be resolved to a type plz hlp me out of this prob
Really impressed with the way you explained Raghav. Thanks a lot
I was looking for Scripting with Python + Appium for Mobile app automation. Will be appreciated if there is one from your end. Thanks
You are most welcome Santhosh, I will plan on this, Can check all tutorials here - automationstepbystep.com/
Very useful Videos... thank you Raghav :) Keep the good work up (y)
Thanks a ton Ayushi
The best content for Appium.
Thanks
@@RaghavPal I am getting below Error:
Exception in thread "main" 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: Could not find 'aapt.exe' in ["C:\\Users\\azhar\\Desktop\\android-sdk\\platform-tools\\aapt.exe","C:\\Users\\azhar\\Desktop\\android-sdk\\emulator\\aapt.exe","C:\\Users\\azhar\\Desktop\\android-sdk\\tools\\aapt.exe","C:\\Users\\azhar\\Desktop\\android-sdk\\tools\\bin\\aapt.exe"]. Do you have Android Build Tools installed at 'C:\Users\azhar\Desktop\android-sdk'?
Raghav,
I learnt many basics from your classes like Appium, SoapUI, etc..
Please accept this as a token of gratitude.
Thanks Sharath
Excelent!!! thanks for teach us.
Always welcome Monica
Thanks for such a useful video I was facing some errors after checked ur video and implemented the same its successfully running now...thanks Ragav
Great to know this Keerthana.. keep learning..
thanks Raghav, This tutorial was very helpfull
Glad it helped Carol
very clear explanation.. thank you bro... It is working
Most welcome Ramya
Hi Raghav ,
Thanks for these tutorials really so much knowledge . I have one query while i am checking my app for app activity so in my app there are 4 app activities ? what i will use ?
Thanks!
Hi Rahul, you can run the command dumpsys window windows | grep -E ‘mCurrentFocus’ on command line and get the app activity
www.automationtestinghub.com/apppackage-and-appactivity-name/
Thanks alot sir, your videos are very clear
Most welcome Ntando
Very nice video, thank you very much from Germany 🙏
So nice of you
Thank you for such a detailed video. My test code while testing the calculator is giving out the same result for different values entered each time based on id. Can you assist?
Hi Piyush, check the object locators you have used, Most probably they are not finding unique objects and therefore clicking of diff buttons
Really very helpful thank you so much...
You're very welcome Chaitanya
Great work Raghav.
Thanks Awais
Great session Raghav.
Thanks Konda
Brilliant videos. I liked the approch and effort you took for creating each and every videos.
Most welcome Vishnu
Hi Raghav, I was able to start the AppiumDriver using the desired capabilities, but I need to use the default capabilities passed by command line. How can I make the driver read the default capabilities instead of the desired ones?
Hi Vitor,
I have not tried but you can use the command line option as shown here - stackoverflow.com/questions/30479511/appium-setting-desired-capabilities-in-both-terminal-and-test-code
appium.io/docs/en/writing-running-appium/server-args/
www.swtestacademy.com/appium-capabilities/
Hi Raghav, after launching calculator application in my pc, for every time after launching it is asking terms and conditons to agree or exit
Hi Praneeth, in case it is asking everytime, you can also automate the step to handle the popup. Or if you have any setting to disable it. You can also check for starting of an existing application rather than installing a new one
My mobile application backend is written with node js. so i want to automate that mobile app.
Can i automate it using appium with java language??
Or would you suggest to automate it using node js?
Kindly reply
You can use java.
Excellent explanation. Appreciate your efforts :)
Glad it was helpful Elavarasi
So glad you're demonstrating this on a Mac. I'm having a hard time with the iOS side
I will do more sessions on mac
Hey....! Really I am very thankfully to you... It's been a month I was struck in environment setup and initial execution.... Ur tutorial helped me to execute my 1st test with 30 mins
So happy to know it helped
hey kesavraj i am also stuck at remote session..Can you help me bro on this?
@@chetanpatil5872 sure.. Can connect via zoom or else?
@@chetanpatil5872 make sure download commend line tool & platform tool..
Set path in system variables
@@kesavarajp9715 I did but not working
Hi Raghav, I'm new to Automation and your videos are really very helpful to me. I want to automate an Android App for my project where I'm near about 50 Activities for the App. In which basis I will choose the activity for setting DesiredCapability of "appActivity".Please help!
Hi Sonali, can try this
1. Unlock mobile device
2. Open CMD
3. Run command : adb devices
4. Run command : adb shell
5. On mobile store open the app that you want to check
6. Run command : dumpsys window windows | grep -E ‘mCurrentFocus’
7. appPackage and appActivity name will get displayed. Copy from here
www.automationtestinghub.com/apppackage-and-appactivity-name/
Hi Raghav, how can I uninstall the app from Android and reinstall the same app for a particular test case(only one test scenario).
NOTE : For the other scenarios one time installation should be good enough.
Hi Srinu, Pls check this - discuss.appium.io/t/install-and-uninstall-android-app/5180/7
stackoverflow.com/questions/38830792/after-my-test-is-executed-i-want-it-to-uninstall-the-app-as-well
Good work, nice tutorial.
Thanks Anand
I am really learning so much from your tutorials ❤
Can you tell me the tool you are using for connecting real device
To show the device screen I used Vysor
Hey Raghav,
Could you plz me
I am getting this error
Could not find or load main class appiumtest.CalculatorTest
Hi Vijay, is it coming while running from command line - Pls check this javarevisited.blogspot.com/2015/04/error-could-not-find-or-load-main-class-helloworld-java.html
Hi Raghav , how can we perform scrolling vertical and horizontally in android device ?
Check this Sudhir bugreaper.blogspot.com/2018/02/how-to-scroll-in-appium.html
Hi Raghav,
I am not able to find the setCapability method on DesiredCapabilities object. Its working fine , When I degraded the selenium version from 3.141.59 to 3.141.5. Thanks in advance
Hi Krishna, will need to check the api documentation for the version 3.141.59. For now you can continue with the ver that is working
Hi raghav
do we need selenium standalone jar as well? for appium
You should not need that Ram, check this - discuss.appium.io/t/jar-files-required-to-run-the-appium-using-selenium/9725
Hi Raghav I have been trying to download the dependencies for the appium. As soon as i paste the dependency in my pom.xml file it throws me an error, with 24 odd errors. Can you please suggest any fix. Thanks Btw the appium dependency will not add any jar file.
Hi N D, will have to see the pom.xml and logs to troubleshoot.
Hello, i've got some error like this when after rebuild my project :
MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
Duplicate class org.apache.commons.logging.Log found in modules jetified-commons-logging-1.2.jar (commons-logging:commons-logging:1.2) and jetified-spring-jcl-5.1.8.RELEASE.jar (org.springframework:spring-jcl:5.1.8.RELEASE)
how to fix this ? thanks
HI Dimas, what is your java ver. Check if this helps - stackoverflow.com/questions/55812717/error-invoke-customs-are-only-supported-starting-with-android-o-min-api-26
what if i use android studio instead of eclipse or vs code?
Hi Mohsin
Using Android Studio with Appium is a viable option for mobile app automation. Android Studio is an integrated development environment (IDE) specifically designed for Android app development, and it provides a range of features and tools that can enhance your Appium automation workflow
If you are already familiar with Android Studio or prefer its features and interface, using it for Appium automation can streamline your workflow and provide a more efficient development experience
Hi Raghav,
I download App info apk to check appPackage & appActivity.
When I check the app activity for any app(Ex: Calculator, Calender) am seeing multiple activities, which one I need to select to launch the apk.
Hi Jeevan, Can try this
1. Unlock mobile device
2. Open CMD
3. Run command : adb devices
4. Run command : adb shell
5. On mobile store open the app that you want to check
6. Run command : dumpsys window windows | grep -E ‘mCurrentFocus’
7. appPackage and appActivity name will get displayed. Copy from here
www.automationtestinghub.com/apppackage-and-appactivity-name/
sir , thank you for the great tutorial , since I don't have android device , can you show tutorial on how to connect to android emulator ? thanks in advance
Hi Moe, I will do a session on this
Just awesome...
Thank you so much 😀
Hi,
while run this code i am getting this type of exception.
java.lang.reflect.InvocationTargetException
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: Error executing adbExec.
Hi Harshit, there are several people who have discussed about this in the comments, Pls check, I am not listing out here as there can are diff solutions that have helped, You may want to try them out
Hi Raghav,
After adding the dependencies I am getting following errros. Please help me to fix the issue.
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 -> org.apache.maven:maven-toolchain:jar:1.0 -> org.apache.maven:maven-core:jar:2.0.6 -> org.apache.maven:maven-project:jar:2.0.6 -> org.apache.maven:maven-plugin-registry:jar:2.0.6: ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-registry:jar:2.0.6: ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-registry:pom:2.0.6 from repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-registry:pom:2.0.6 from/to central (repo.maven.apache.org/maven2): The operation was cancelled. pom.xml /appiumtests line 1 Maven Project Build Lifecycle Mapping Problem
Hi Kundan, Try using the eclipse "Update Maven Project" (ALT+F5) feature end check the option "Force Update of Snapshots/Releases".
stackoverflow.com/questions/39926064/coreexception-could-not-get-the-value-for-parameter-compilerid-for-plugin-execu/41416449
stackoverflow.com/questions/21721357/error-in-pom-xml-maven-build
Hi,
Getting Could not find 'adb.exe' in PATH even though we set android variable in environment variables
.
Hi Amit, pls try this
Step 1: You know where your android-sdk is installed in your system if you didnt changed the location search in ProgramFiles/Android
Step 2: close eclipse.
Step 3: Copy adb.exe in android-sdk/platform-tools/ folder
Step 4: Paste that adb.exe in android-sdk/tools/ folder
Step 5: Now open eclipse go to Windows --> Preferences choose android then click browse and select android-sdk with in few minutes it shows APK levels installed in your system press Applystackoverflow.com/questions/6361349/android-problem-eclipse-cannot-find-adb-exe
@@RaghavPal I can't find Android in eclipse preferences...?
Sirr I am not getting the maven depdecies folder after I save the dependencies in pom.xml file....
And sirr also I am not getting the appium option in working set while creating the new project...
And sirr also there is red cross mark on the appium test icon which is there on the left side project explorer.
Hi Raj, after adding dependencies, you have to save project, and then check, you can also refresh and build again to check maven folder
For working set you can check this dzone.com/articles/eclipse-working-sets-explained
You can goto problems view and see the issue in the project
First thank you so much this tutorials.Someone cant find Udid you have to go your folders SDK then you have to look platform-tools copy adb to tools folder and open cmd and write "adb.exe devices" maybe you will take adb.Win.dll error go and download that thing then send to same folder with adb.exe then open cmd and write you will find :D
thanks for adding
Hi when I m creating my maven project the src/main/resources and sec/test/recourses are missing.....n the script is also not working..plzz help me.. ..what to do
Hi Aditi, hope you have created a maven project. You can also check looking at package explorer
Hey Raghav, instead of connecting to real device, do you have a video how to run my Java automation script against Android simulator /emulator? Thanks
Not yet for android Sai.
Thanks for this awesome tutorial! It would have been great if you have made a udemy free course for all these appium tutorials
Hi Dima, I will try to add this on Udemy
@@RaghavPal Thanks Raghav! looking forward to it
Hi thanks for this video, but i get an issue. why i can't see anything inside working set box in eclipse?
Hi Cristian, will need to see details for this
Hi Sir, Your Videos are really helpful and awesome , I am not able to start application on device . the error is something like this , 'io.appium.uiautomator2.server' is not installed
Hi Suraj, try to install the latest appium or beta ver and check again
npm uninstall -g appium && npm install -g appium@beta
Hi Raghav,
I am getting below error on MAC can you help me over here.
Exception in thread "main" 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: Could not find 'aapt' in PATH. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
Hi,
aapt.exe is the Android Asset Packaging Tool and is part of the Android SDK. Can you confirm that you have aapt.exe somewhere on your machine? There are specific directories that the script is looking in to find it. You might want to try reinstalling the Android SDK.
I was reading some posts that aapt.exe may be named aapt2.exe for some SDKs. Could you check to see if that file exists on your system? You should be able to find it in:
C:\Users\\AppData\Local\Android\sdk\build-tools\
If it does exist, you might be able to create a shortcut named “aapt.exe” to that file.
forum.katalon.com/t/could-not-find-aapt-exe/10922/10
A user solved it using below steps:
1 I installed Android Studio and
2 installed SDK from Android Studio.
export ANDROID_HOME=/Users/darya1/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
3 Edit the configuration setting of Appium server to point to the ANDROID_HOME and JAVA_HOME.
Thanks for the video.
Would you please help me in this error..?
An unknown server-side error occurred while processing the command. Original error: zipAlignApk failed. Original error: spawn UNKNOWN. Stdout: 'undefined'; Stderr: 'undefined'
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
Hi Huda, I was checking online for this and found comments like
The problem is with the SDK version 29. I had to downgrade and built the APK again.
The SDK ver may be diff in your case
Check these
stackoverflow.com/questions/55525330/appium-encountered-internal-error-running-command-error-zipalignapk-failed
github.com/appium/appium/issues/10377
Hi Raghav, great videos man.
I am getting an error in the pom file.
Errors running builder 'Maven Project Builder' on project 'appiumtests'.
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
PLEASE HELP!!
Hi Syed, this will help
stackoverflow.com/questions/12533885/could-not-calculate-build-plan-plugin-org-apache-maven-pluginsmaven-resources
Thanks a lot, Raghav!
Most welcome Deepali
want to validate any text in the mobile application. I am not able to use "Assert.asertEqual" something action for mobile text in (appium+Maven+Java) Project.
Hi Vinod, you will have to get the text from the browser first. You car search more on "Appium How to get text from element"
Hi Raghav great tutorial i am learning a lot from your videos, 1 issue when i run the code i get the same success message in console but in my android mobile nothing is happening, can u pls help
Hi Amrita, pls check the connection is done properly, the device settings etc as shown. You may also try a diff device if you can
Thanks for sharing this video Raghav. Is the next video available?
Hi Akhila, you will find all here - ua-cam.com/play/PLhW3qG5bs-L8npSSZD6aWdYFQ96OEduhk.html I am working on some videos and will be available in a few days. Keep watching.
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Pls check this - stackoverflow.com/questions/12533885/could-not-calculate-build-plan-plugin-org-apache-maven-pluginsmaven-resources
Hi, I got the error continuous in the variable. Please suggest any comments.The error is "The type AndroidDriver is not generic; it cannot be parameterized with arguments "
Hi Ranjit, MobileElement is replaced with WebElement discuss.appium.io/t/mobileelement-library-not-being-added/35192
C:\Users\stikku.EAD>adb devices
'adb' is not recognized as an internal or external command,
operable program or batch file
Hi Pls check if you have set path of adb in env variables (system variables)
Pls check this : stackoverflow.com/questions/8744758/adb-is-not-recognized-as-internal-or-external-command-on-windows
Hi Rahgav, my appium (sdkmanager) does not support java version 11, but accepted version 8. so I have to uninstalled java 11 to install java 8, but now my eclipse is request for java 11 to run, please what can I do
Hi Niyi, For Java 11 Reference: stackoverflow.com/questions/60440509/android-command-line-tools-sdkmanager-always-shows-warning-could-not-create-se
1. Download latest Command line tools from android i.e. commandlinetools-win-6200805_latest.zip
2. Unzip the downloaded file
3. Create directory for storing commandline tools somewhere on your disk, with following path included: android/cmdline-tools/latest. Basically when You unzip this Cmd line tools, just rename tools directory to latest and make sure You put this latest folder in android/cmdline-tools directory somewhere on your disk
4. Create ANDROID_HOME environment variable for directory that stores the cmdline tools directory location like: C:\YourLocationWhereYouStoreTheDirectory\android\cmdline-tools\latest
5. Create new entry in Path environment variable as %ANDROID_HOME%\bin
Hi Raghav Pal,
You have done a fabulous job here. It is very simple and easy to understand.
I have one Question... How can i get 'App package name & App Activity name ' on emulator ?
Hi, You can add some apps like APK Info from playstore and use it
Hi Raghav,
Error is now resolved!
hence it seems some compatible issue with selenium with appium drivers.
Great to know Lalit
Hi Raghav. When I try to import MobileElement like in 16:17, it says that the element is not found. I made sure I added appium to dependencies in pow file but it doesn't help. Can you please advice what also I can do?
Hi Dildora
If you're facing an issue where the MobileElement class is not found, despite adding Appium as a dependency in your pom.xml file, here are a few steps you can take to troubleshoot the problem:
Verify dependency: Double-check your pom.xml file to ensure that the Appium dependency is correctly added. Make sure you have the correct group ID, artifact ID, and version specified. Here's an example of how the dependency should look:
io.appium
java-client
7.5.1
Update Maven project: In your IDE (such as Eclipse or IntelliJ IDEA), try updating the Maven project. Right-click on your project, go to "Maven," and select "Update Project." This will ensure that all the dependencies specified in the pom.xml file are downloaded and resolved correctly.
Check class imports: Make sure you have the correct import statement for MobileElement in your code. The import statement should look like this:
import io.appium.java_client.MobileElement;
Ensure that the import statement is not marked as unused or removed by any code cleanup tools or IDE settings.
Clean and rebuild: If you've made any changes to the pom.xml file or imported classes, try cleaning and rebuilding your project. This will ensure that any compilation issues or conflicts are resolved.
Check Appium version compatibility: Ensure that the version of the java-client dependency in your pom.xml file is compatible with the version of Appium you are using. It's recommended to use a version that is compatible with your Appium server version.
Check Appium server setup: Ensure that you have set up the Appium server correctly. Make sure the server is running and the desired capabilities are properly configured in your test script.
If the issue persists after trying these steps, please provide more details about your project setup, including the relevant sections of your pom.xml file and any relevant code snippets. This will help in further diagnosing the problem and providing a more specific solution
Hi Raghav, I am getting Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Original error: Failed to connect to /127.0.0.0:4723
Can you plz help me with it.
Hi Priti, pls ensure that appium server is running. This can also be due to appium ver. Pls check these links
stackoverflow.com/questions/43409349/unable-to-create-new-remote-session-appium
discuss.appium.io/t/org-openqa-selenium-sessionnotcreatedexception-unable-to-create-new-remote-session-solved/14303/8
Hi Rahul,
Whats the reason for Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS error while running on real device.
Hi Mathew, Check if this is enabled
USB debugging -Debug mode when USB is connected
Install via USB -Allow installing apps via USB
USB debugging (Security Settings) - Allow granting permissions and simulating input via USB debugging
pls see if this helps - github.com/Genymobile/gnirehtet/issues/5
I'm getting a InvocationTargetException saying that "The file at '/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk' does not exist or is not accessible"
In fact there is no such file, but how can I get it? I'm using appium through the command line only
Hi Vitor, are you using appium desktop or appium downloaded as npm package. You can try the npm package. This link has some useful information - github.com/appium/appium-desktop/issues/1080
.Thank you for your hard work. When I type the "npm install -g appium" I get the Error: Cannot find module 'C:\Program Files
odejs
ode_modules
pm\bin
ode_modules
pm\bin
pm-cli.js' Some reason the "node_modules
pm\bin" is repeating. Is this the wrong path? When I try "npm -v" I also get the long path. I do have my files on the correct path, "C:\Program Files
odejs
ode_modules
pm\bin". I checked my Env Variables, and they look correct. I also have a sec0ond C:\Program Files
odejs (do I need both?)
Hi Mike,
This error message typically indicates an issue with the npm installation. Here are some steps you can try to resolve the issue:
Uninstall Node.js and NPM from your system. Make sure to remove all related files and folders.
Reinstall Node.js and NPM from the official website (nodejs.org/en/download/).
After installation, open a new command prompt and type npm -v to confirm that npm is installed correctly and the path is set up properly.
Then, try running the command npm install -g appium again to install Appium globally.
If the issue persists, try running the command with administrative privileges by running the command prompt as an administrator.
Regarding the duplicate path, having multiple installations of Node.js in different directories is not recommended as it can cause conflicts and confusion. You can try removing the duplicate directory to avoid any potential issues.
how to remove this error in eclips driver = new AppiumDriver(cap);
please give the solution of this.
A user comment
had the same problem; here is what worked for me:
in my code, i replaced these 2 lines:
AppiumDriver driver;
driver = new AppiumDriver(url, caps);
by the following lines:
WebDriver driver;
driver = new RemoteWebDriver(url, caps);
hello raghav , plz slove my error i am getting
could not start new session,. possible causes are invalid address of remote server or browser startup failure
Hi Niharika, this can help
discuss.appium.io/t/could-not-start-a-new-session-possible-causes-are-invalid-address-of-the-remote-server-or-browser-start-up-failure/9158
How to import the mobileElement im getting error :The type AppiumDriver is not generic; it cannot be parameterized with arguments
Beeranna
To import the MobileElement class in Appium Java, you can use the following import statement:
```java
import io.appium.java_client.MobileElement;
```
This will import the MobileElement class from the Appium Java client library.
If you are getting the error `The type AppiumDriver is not generic; it cannot be parameterized with arguments `, it means that you are trying to use the AppiumDriver class with the MobileElement type parameter. However, the AppiumDriver class is not generic, so it cannot be parameterized with any type argument.
To fix this error, you can remove the type parameter from the AppiumDriver class. For example:
```java
AppiumDriver driver = new AppiumDriver();
```
This will create a new AppiumDriver instance that is not parameterized with any type argument. You can then use the AppiumDriver instance to interact with mobile elements using the MobileElement class.
Here is an example of how to use the MobileElement class to interact with a mobile element:
```java
MobileElement element = driver.findElementByAccessibilityId("My Element");
element.click();
```
This code will find the mobile element with the accessibility ID "My Element" and click on it.
I hope this helps
Hi Ragav, I am not getting import option when I place a mouse over on Desired Capabilities in eclipse ....Can u plz sort it out?
Hi Kranthi, you can try keyboard shortcut ctrl + shift + o to manage imports
Thank u.......
I have a lot of activities, which one to use? Also when running the code. I get, cannot find symbol?
Hi Yasin,
1. Unlock mobile device
2. Open CMD
3. Run command : adb devices
4. Run command : adb shell
5. On mobile store open the app that you want to check
6. Run command : dumpsys window windows | grep -E ‘mCurrentFocus’
7. appPackage and appActivity name will get displayed. Copy from here
www.automationtestinghub.com/apppackage-and-appactivity-name/
Hi Raghav
While going through your code when using mobile element for appium driver I am getting this error " Bound Mismatch : the type mobile element is not a valid substitute for the bounded parameter of the type AppiumDriver "
Could you please help me to resolve this issue
Diksha
The error message "Bound Mismatch: the type MobileElement is not a valid substitute for the bounded parameter of the type AppiumDriver" means that you are trying to use the `MobileElement` class as a parameter for the `AppiumDriver` class. The `AppiumDriver` class takes a generic type parameter, which must be a subclass of the `WebElement` class. The `MobileElement` class is not a subclass of the `WebElement` class, so it is not a valid substitute for the generic type parameter.
To fix this error, you can either:
* Change the generic type parameter of the `AppiumDriver` class to `MobileElement`.
* Change the type of the `MobileElement` object to `WebElement`.
Here is an example of how to change the generic type parameter of the `AppiumDriver` class:
```
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
public class AppiumTest {
public static void main(String[] args) {
// Create an AppiumDriver object with the generic type parameter set to MobileElement.
AppiumDriver driver = new AppiumDriver();
// Find the element by its ID.
MobileElement element = driver.findElementById("my_element_id");
// Do something with the element.
element.click();
}
}
```
Here is an example of how to change the type of the `MobileElement` object to `WebElement`:
```
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import org.openqa.selenium.WebElement;
public class AppiumTest {
public static void main(String[] args) {
// Create an AppiumDriver object.
AppiumDriver driver = new AppiumDriver();
// Find the element by its ID.
WebElement element = driver.findElementById("my_element_id");
// Do something with the element.
element.click();
}
}
```
I hope this helps
Hi Raghav,
I am getting the Exception while running the script
java.lang.reflect.InvocationTargetException
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: The JAVA_HOME environment variable must be set for Android Tools to work properly
Hi Neelesh, are the env variables set on your system, Pls check again, There are other comments with the same issue, check them
Hey raghav! For some reason when I run my code, the app opens, but it gives me a java.lang.NullPointerExeption in the console. How can I solve?
Hi Samuel, will need to check the logs, Also check the setup again
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error, insert "}" to complete Block
at appiumtests.CalculatorTest.main(CalculatorTest.java:14)
,hi Raghav I got this error ,can u help how to resolve from this error
As mentioned in error message you are missing a } in your code. Pls check
i really like the video clip
Glad to know this Nagag
Hi Raghav, i tried the SAME but got below error. Please help
Encountered internal error running command: A new session could not be created. Details: java.lang.IllegalStateException: UiAutomation not connected!
[debug] [W3C] io.appium.uiautomator2.common.exceptions.SessionNotCreatedException: java.lang.IllegalStateException: UiAutomation not connected!
[debug] [W3C] at io.appium.uiautomator2.handler.NewSession.safeHandle(NewSession.java:59)
Hi Abhijit, see if this helps - stackoverflow.com/questions/47854705/google-fabric-uiautomation-not-connected
Thank you so much.
Most welcome
Hi Raghav
I am trying to execute script but it showing below error ?
Exception in thread "main" 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: You must include a platformName capability (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 140 milliseconds
Hi Pavan, as shown in the error in your desired capabilities add platformName
e.g. "platformName": "Android"