Appium
is widely used automation tool for Mobile Applications and this post
will help you to setup the Appium with Android Studio including writing
and executing your first test case using Appium.If you are not familiar
with android studio then also this post will definitely help you to to
setup Appium. I hope this post helps you to setup your Appium Test Environment
quickly. If you face any issues do post your questions. Let is get started with how to install Appium and configure in Android Studio.This is very easy step by step tutorial for appium setup in android studio.
- Download -
- Install Android Studio please follow the steps given in the link to install android studio step by step on windows machine click here
- After installation of android studio ,open android studio and create a new project - How to create android project?
5. Click on build.gradle in app you will see all the libs added like below screenshot add junit:4.12.Sync the project or Re-build the project. It should show "Build Successful Message"
Appium Gradle Dependency |
6. Now you are ready to write your first test case - right click on the package and click on "Create Java Class". Copy given test case sample.
7. Running the Test case-
- Click on build variant
- Select Unit Testing
- Start the appium server with Specific port "4444"click here
- Connect device with USB debugging on or start an emulator.
- Right click on the test class and click on "Run"
import java.net.MalformedURLException; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class WaitTests { WebDriver driver; @Before public void setUp() throws MalformedURLException { // Created object of DesiredCapabilities class. DesiredCapabilities capabilities = new DesiredCapabilities(); // Set android deviceName desired capability. Set your device name. capabilities.setCapability("deviceName", "XT1562"); // Set BROWSER_NAME desired capability. It's Android in our case here. capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android"); // Set android VERSION desired capability. Set your mobile device's OS version. capabilities.setCapability(CapabilityType.VERSION, "6.0.1"); // Set android platformName desired capability. It's Android in our case here. capabilities.setCapability("platformName", "Android"); // Set android appPackage desired capability. It is // com.android.calculator2 for calculator application. // Set your application's appPackage if you are using any other app. capabilities.setCapability("appPackage", "com.android.calculator2"); // Set android appActivity desired capability. It is // com.android.calculator2.Calculator for calculator application. // Set your application's appPackage if you are using any other app. capabilities.setCapability("appActivity", "com.android.calculator2.Calculator"); // Created object of RemoteWebDriver will all set capabilities. // Set appium server address and port number in URL string. // It will launch calculator app in android device. driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); } @Test public void testFirstCalculator() { // Click on DELETE/CLR button to clear result text box before running test. driver.findElements(By.xpath("//android.widget.Button")).get(0).click(); // Click on number 2 button. driver.findElement(By.name("7")).click(); driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS); } @After public void End() { driver.quit(); } }
Once your Setup is Complete Learn more About Appium with this simple Step by Step
APPIUM TUTORIAL
Note - Learn More About Android Studio Basic Features and Functionality HERE .
If you want to learn more about Testing with Emulators and Real Devices do refer this article -
Real Device vs Emulator Testing Ultimate Showdown
Please share your feedback in comments section below and join QA-Automated
for latest post updates.Happy Testing !!!
you have mentioned
ReplyDeleteAdd the Appium jars into your project - click on project -> click on app->copy all the jars in lib. Select the copied jars except Selenium, Java client and Junit Jar ,then right click on it and click on "Add as Library".
But I do not see "lib" folder in Android Studio's project explorer, though I see in Windows Folder Structure.
And also I do not see any option as Add As Library in any context menu, do we just need to copy paste all jar files in lib folder in Windows Explorer ??
click on teh project structure then on top left corner there is drop down -> check if android is selected then change and select "project" -> then click on app-> libs and then you can right click on libs and copy the jar files.
DeleteHi there,
DeleteWhen I click Project Structure, I do get these drop down menus when I click Project. I could be using a more updated version of Android studio then you?
Instead of being able to upload the jar files, I added them via app -> dependencies through Maven. Would this still be sufficient to run the test code above? When i create a test class via src -> main -> java nothing can be resolved.
Any thoughts on this?
In your project structure search lib folder add the file there and as well as in gradle dependencies then only you can see results.
DeleteSelect project in left side strictust of android studio.you will see lib folder
DeleteWhen I copy the above code, getting error at the below mentioned lines. Let us know the used interfaces for better understaning. Thanks!
ReplyDeleteservice.start();
ReplyDeletereader.readFile();
Remove these two lines as these I added to start Appium server using java code . This tutorial is also there ar my blog -http://qaautomated.blogspot.in/2016/01/how-to-start-appium-server-using-java.html
ReplyDeleteHi Anuja,
ReplyDeleteWhich are the packages i should import in my class?
import org.junit.After;
ReplyDeleteimport org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.IOException;
import java.net.URL;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.remote.MobileCapabilityType;
thanks for your tutorial, in your source code Do I need to place the sample.apk at c://apk// ,
ReplyDeletebut I don't have the file "sample.apk".
Looking forward to your answer . Thank you.
Thanks for reading .
ReplyDeleteYou need to place path of your apk which you want to test
I get an unresolved symbol error at "driver = new AndroidDriver...." I did some digging and it seems that AndroidDriver is part of org.openqa.selenium, but it does not show up in my org.openqa.selenium package.
ReplyDeleteAndroidDriver is the unresolved symbol.
DeleteCheck that you added java-client-3.2.0.jar which you can download from the link I have given in the post.becasue AndroidDriver is part of this package
Deleteimport io.appium.java_client.android.AndroidDriver;
This comment has been removed by the author.
ReplyDeleteHii Anuja i got error while testing
ReplyDeleteTest running failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
Empty test suite.
PLz help me
Thank U
There can be different reasons to get this error -
ReplyDelete1. create your test case in scr-> main-> java
2. select build variant as Unit Test
3. If u r running in real device check USB debugging is on and connected as file transfer
Hi Anuja,
ReplyDeleteCould you please let me know can we configure the TestNG for this?
If yes please provide the steps to doing that.
Thank you!
- Manish B
Hi Manish,
DeleteWe can configure TestNG for this and I have addes a blog post so that you can do it . please check out this link - http://qaautomated.blogspot.in/2016/03/appium-setup-in-android-studio-with.html
Regards,
Anuja
Hi Anuja,
ReplyDeleteThe 2nd link in the download section, Appium jar files in the google drive - From where were these files downloaded?
I googled and downloaded the necessary files.
DeleteHi Anuja,
ReplyDeleteThis document is very well.
I Followed this same steps but
In test case1 shows compile error with
findElementByID and
Asser
Hi Anuja,
ReplyDeleteThis document is very well.
I Followed this same steps but
In test case1 shows compile error with
findElementByID and
Asser
Hi sravanthi, you can click on the error and import the required class.If you are not getting the imports then check your dependencies and libs
DeleteI tried ,But imports also not working for
Deletethis below lines
driver=new AndroidDriver("http://127.0.0.1:4444/wd/hub",cap);(e:connot resolve constructor)
driver.findElementByID("Example").click();(e.cannot resolve method findElementByID) Asser.assertTrue(driver.findElementByID("Example").isDisplayed));
(e:cannot resolve symbol Asser)
hi there, I have the same problem...any solution for this ? thanks in advance.
DeleteYes I am having same problem. If u got the solution for this. Please tell me
DeleteIf your imports are not working check ur jars in lib folder and build.gradle. If anything is missing you will not get imports
DeleteHi Anuja, thanks for the tutorial, but I'm getting the same errors.
DeleteI have imported the library and compile gradle but nothing, I always get the same error as Sravanthi M
driver=new AndroidDriver(cap);(constructor have only one parameter DesiredCapabilities)
Deletedriver.findElementById("Example").click();(Change method name findElementByID() to findElementById) Assert.assertTrue(driver.findElementById("Example").isDisplayed));
(There is no sysmbol named Asser, Change it to Assert)
Hi, this solved my errors. thanks
DeleteI'm not able to solve this error since last four hours. please guide to remove it
ReplyDeleteI'm getting this in console
java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:144)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
at org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:251)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.(ApacheHttpClient.java:228)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:89)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:63)
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:36)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:167)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:69)
at appiumtest.cogitate.us.appiumtest.ExampleUnitTest.testCaseSetup(ExampleUnitTest.java:37)
Process finished with exit code 0
Did you got the solution for this error? I am getting the same error.
Deletedo we require seperate android sdk or android studio will fulfill the purpose..
ReplyDeletebecaose wile running my first appium test case on ubuntu using android studio there is an error android_home is not set.
android studio is enough you can download android sdk with sdk manager inside android studio . You need to set Android_Home to execute anything using android studio
DeleteThanks for the article. Do we have some build dependency file for including the Appium Jar files and Appium Client Library - instead of manually downloading them?
ReplyDeleteI dnt think so we have it. I will still explore to know more.Share with us if you find out.
DeleteThis is great initiative. Thanks for the article and answering questions.
ReplyDeleteCan you create this project and check in to GitHub, so that other users can import it in to Android Studio. This way, most people can be successful in getting Appuim environment in Android Studio, quickly and easily. Also, some one can even fix/update GitHub in future - to keep it current.
Thanks for your comments I will try to do it :-)
DeleteHi,
ReplyDeleteHow to copy all the jar files from drive? I am new to this automation so pls help me.
Hi, Just download the jar files from the drive . Then select all and copy it. Then go to android studio project -> app> lib folder and paste all files.
DeleteRegards,
Anuja
Add below code in app -> build.gradle
ReplyDeletepackagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
Hi,
ReplyDeleteI've coped all jar files and import properly and even if getting below errors..
driver=new AndroidDriver("http://127.0.0.1:4444/wd/hub",cap); error as Cannot resolve constructor 'AndroidDriver(java.lang.String, org.openqa.selenium.remote.DesiredCapabilities)'
and Cannot resolve symbol 'Asser' ...
It would appreciate if you help me on this
Thanks
Srihari
you can check whether yoy have imported required packages -
Deleteimport org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.IOException;
import java.net.URL;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.remote.MobileCapabilityType;
I also had the same issue and I found that using it like this can solve the issue - driver=new AndroidDriver (new URL("http://127.0.0.1:4444/wd/hub"), cap);
DeleteNotice that "import java.net.URL;" would be needed.
DeleteThis comment has been removed by a blog administrator.
ReplyDeleteI am not able to change my build variant and I am getting java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Kernel32 error.
ReplyDeleteI have posted a question on stackoverflow here http://stackoverflow.com/questions/40396108/calling-stop-on-appiumdriverlocalservice-fails.
This happens when I try to stop the server.
You can share build.gradle dependency section with me. so that I can get some more clarity.
DeleteGetting an exception at
ReplyDeletedriver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), (Capabilities) capabilities);
as follows-
java.lang.ClassCastException: org.openqa.selenium.remote.DesiredCapabilities cannot be cast to org.openqa.selenium.Capabilities
Any help?
Thanks for beautiful tutorial. I found this tutorial very late but BINGO :). But it's clear my concept with beautiful explanation
ReplyDeleteI am glad that it helped you. Thanks for visiting.Follow me on FB or G+ to get latest post updates. :-)
DeleteThanks Anuja. The videos were helpful.
ReplyDeletehi getting the below error in appium
ReplyDeleteinfo: [debug] Error: 'java -version' failed. Error: spawn ENOENT
> at [object Object]. (C:\Program Files\Appium\node_modules\appium\lib\devices\android\android-common.js:1057:17)
> at exithandler (child_process.js:633:7)
> at ChildProcess.errorhandler (child_process.js:649:5)
> at ChildProcess.EventEmitter.emit (events.js:95:17)
> at Process.ChildProcess._handle.onexit (child_process.js:795:12)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)","origValue":"'java -version' failed. Error: spawn ENOENT"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 33.932 ms - 208
Wow, very concise and effective tutorial on Appium with Android Studio. It saved my day.
ReplyDeleteThank you !!
Hey, thanks for stopping by at my blog. and I a glad it saved your day. stay connected for more tutorials
DeleteHe thanks for stopping by at my blog. and I a glad it saved your day. stay connected for more tutorials
ReplyDeleteHello
ReplyDeleteplease upload the vedio from another account it was really helpful.
Hi,
DeleteI have decided to wait for 1 day for response as I have not violated any terms or else will update from other account.
Regards,
Anuja
This comment has been removed by the author.
ReplyDeleteThanks:)
ReplyDeleteI have one more query how to automate the toast message in android? please suggest.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
ReplyDeleteat sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
ReplyDeleteCommand duration or timeout: 0 milliseconds
Build info: version: 'unknown', revision: '86a5d70', time: '2017-02-16 07:47:51 -0800'
System info: host: 'LENOVO-PC', ip: '192.168.0.106', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_76-release'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:161)
ReplyDeleteat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:64)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155)
at com.example.lenovo.android.Cbsk.setUp(Cbsk.java:55)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
can you say how to clear this issue
ReplyDeleteHi, Can you try with started Appium server on different port number.
Deletemake sure you have latest appium server and appium java client.
Regards,
Anuja
me too had the same issue! solved it! thanks :))))))
DeleteHi, I have some problems when i created a project in android studi, The gradle showed this error:
ReplyDeleteError:(41, 17) Failed to resolve: junit:junit:4.12
Error:Failed to resolve: com.squareup:javawriter:2.1.1
Error:Failed to resolve: javax.inject:javax.inject:1
Error:Failed to resolve: javax.annotation:javax.annotation-api:1.2
Error:Failed to resolve: com.google.code.findbugs:jsr305:2.0.1
Error:Failed to resolve: org.hamcrest:hamcrest-library:1.3
Error:Failed to resolve: com.squareup:javawriter:2.1.1
please i followed each steps of yours Tutorial.. I need Help...Thank
Hi, Please make sure you have latest version of appium client and server along with selenium jars. Plus you have latest version of JAVA and Android studio installed. You can watch video also to follow exact steps.
DeleteTHanks,
Anuja
Hi,
ReplyDeleteThanks for this tutorial,
I followed all the steps you mention and imported all the jars you mentioned in the video and blog,
However, when pasting the code, the following imports are unrecognized -
import org.openqa.selenium.By;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
(By, remtoe, and support are colored in red).
as a result DesiredCapabilities can't be resolved and the code doesn't compile...
Do you have a suggestions to what am I doing wrong ?
Hi, There is one jar ouside the folder when you extract selenium jars. you are missing that jar. thats why you are getting that error.
DeleteThank you, that did the trick
DeleteI am still facing the same issue :(
DeleteWill you please share with me you email so that I can share screenshot of that particular error. As I am totally new to automation so I'm feeling way frustrated after spending alot of time in configuration and now these errors are coming up :(
my email = waqas.ahmed@visionx.io
hi, your tutorial is to good but i have a problem, when i run the project the following error is shown
ReplyDeleteError:Execution failed for task '
:app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException:
com.android.builder.packaging.DuplicateFileException:
Duplicate files copied in APK META-INF/LICENSE File1:
C:\Users\Jolta\AndroidStudioProjects\MytestingApp\app\libs\httpmime-4.5.2.jar File2:
C:\Users\Jolta\AndroidStudioProjects\MytestingApp\app\libs\xercesImpl-2.11.0.jar File3:
C:\Users\Jolta\AndroidStudioProjects\MytestingApp\app\libs\httpclient-4.5.2.jar File4:
C:\Users\Jolta\AndroidStudioProjects\MytestingApp\app\libs\cglib-nodep-3.2.4.jar File5:
C:\Users\Jolta\AndroidStudioProjects\MytestingApp\app\libs\httpcore-4.4.4.jar
Thank you by the tutorial, I helped me a lot. I am new about moviles test theme and i have a doubt: How am i generate the code of the application who i want to test? that is, the bibliographies almost always give me a example code but they dont tell me where are they generate the test code?
ReplyDeleteI would like I know this, please help me.
I started the test´s world with visual studio, microsoft test manager and selenium for web and desktop application the last year, and i liked it.
ReplyDeleteAt present I am interested in automated mobile testing and i am working with appium and android studio. I have accomplished to do test examples but i dont understand How am i generate the code of the application who i want to test? the examples come with yours code.
I saw examples with Appium on Mac and i have seen how is it generate the code.
I have not seen test examples on windows where it is explain the generate test code whit appium and android studio.
Thank you for yours attention
Hi Anuja,
ReplyDeletei m getting this when i run the code
debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id","sessionId","id"]} and you sent ["desiredCapabilities","requiredCapabilities","capabilities","alwaysMatch","firstMatch"]
please help me out for this issue
regards,
jay
Hi, Can you share your code too.
DeleteRegards,
Anuja
Hi Anuja,
ReplyDeleteFirstly thanks a lot for this great tutorial, it really helped me get started (otherwise I was really stuck for the last 2 days going through so many blogs but none helped really).
I have followed your tutorial and set up environment on CentOs -
I have 2 problems -
(1) I get NullPointer Exception while initializing the driver at
"driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);"
When I start my appium server (locally) - I see ->
Welcome to Appium v1.6.3
[Appium] Appium REST http interface listener started on 0.0.0.0:4723.
HOW CAN ANY SERVER START AT 0.0.0.0:4723 ?
(2) After Exception, I see following ouput on server ->
[MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","capabilities","sessionId","id"]} and you sent ["desiredCapabilities","requiredCapabilities","capabilities","alwaysMatch","firstMatch"]
[HTTP] <-- POST /wd/hub/session 400 5 ms - 243
--> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.calculator2","appActivity":"com.android.calculator2.Calculator","browserName":"Android","platformName":"Android","deviceName":"SM-T230NU","version":"4.4.2"},"requiredCapabilities":{},"capabilities":{"desiredCapabilities":{"appPackage":"com.android.calculator2","appActivity":"com.android.calculator2.Calculator","browserName":"Android","platformName":"Android","deviceName":"SM-T230NU","version":"4.4.2"},"requiredCapabilities":{}},"alwaysMatch":{"appPackage":"com.android.calculator2","appActivity":"com.android.calculator2.Calculator","browserName":"Android","platformName":"Android","deviceName":"SM-T230NU","version":"4.4.2"},"firstMatch":[]}
WHY BAD PARAMETERS ??
I am trying to follow the exact steps you described in your video.
Please help!
Most of times i face this error.
ReplyDeletehow to resolve these error.
please guide me.
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
hi
ReplyDeletewhen is add the jars to lib in the project i get below error:
Error:Failed to open zip file.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
Please help here
hi I am getting the FirstTest class name grayed out and it says that Class FirstTest is never used .I followed your steps and also see that import org.openqa.selenium.remote.CapabilityType;
ReplyDeleteimport org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
these are all grayed out please advice
Hi,
DeleteThis not actual error it is just a extra info about the class.It will not affect execution
Regards,
Anuja
This comment has been removed by the author.
ReplyDeleteMy class is not getting executed though as it is greyed out.
ReplyDeleteHi,
DeleteMake sure you have used Junit Annotations correctlty.
You have created clss in src->java -> this path..
Another way of exsution select test case name and right click and run.
Thanks,
Anuja
hi That is correct it is under /test/java/FirstTest
ReplyDeleteHi Anuja,
ReplyDeleteThis is a great tutorial and I was able to follow i t step by step but I run into this error now.
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.calculator","appActivity":"com.android.calculator.Calculator","browserName":"Android","platformName":"Android","deviceName":"9039262e","version":"6.0.1"},"requiredCapabilities":{},"capabilities":{"desiredCapabilities":{"appPackage":"com.android.calculator","appActivity":"com.android.calculator.Calculator","browserName":"Android","platformName":"Android","deviceName":"9039262e","version":"6.0.1"},"requiredCapabilities":{}},"alwaysMatch":{"appPackage":"com.android.calculator","appActivity":"com.android.calculator.Calculator","browserName":"Android","platformName":"Android","deviceName":"9039262e","version":"6.0.1"},"firstMatch":[]}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","capabilities","sessionId","id","sessionId","id","sessionId","id"]} and you sent ["desiredCapabilities","requiredCapabilities","capabilities","alwaysMatch","firstMatch"]
Can you advice?
Thank you so much..Your blog was really helpful. Keep Going...
ReplyDeleteI am facing problem to configure appium and android studio in mac os. So if is it possible to share any video for mac os. And Please explain in brief how to configure this in mac os.
ReplyDelete
ReplyDelete:app:transformClassesWithDexForDebug
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: Dex cannot parse version 52 byte code.\nThis is caused by library dependencies that have been compiled using Java 8 or above.\nIf you are using the \u0027java\u0027 gradle plugin in a library submodule add \ntargetCompatibility \u003d \u00271.7\u0027\nsourceCompatibility \u003d \u00271.7\u0027\nto that submodule\u0027s build.gradle file.","sources":[{}],"original":"UNEXPECTED TOP-LEVEL EXCEPTION:\njava.lang.RuntimeException: Exception parsing classes\n\tat com.android.dx.command.dexer.Main.processClass(Main.java:781)\n\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:747)\n\tat com.android.dx.command.dexer.Main.access$1200(Main.java:88)\n\tat com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1689)\n\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)\n\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)\n\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)\n\tat com.android.dx.command.dexer.Main.processOne(Main.java:695)\n\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:592)\n\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:321)\n\tat com.android.dx.command.dexer.Main.run(Main.java:292)\n\tat com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)\n\tat com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:174)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\nCaused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)\n\tat com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:476)\n\tat com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)\n\tat com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)\n\tat com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)\n\tat com.android.dx.command.dexer.Main.parseClass(Main.java:793)\n\tat com.android.dx.command.dexer.Main.access$1600(Main.java:88)\n\tat com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1728)\n\tat com.android.dx.command.dexer.Main.processClass(Main.java:779)\n\t... 16 more\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I am getting this error .plz help me
Error:(8, 27) error: cannot find symbol class By
ReplyDeleteError:(10, 34) error: package org.openqa.selenium.remote does not exist
Error:(11, 34) error: package org.openqa.selenium.remote does not exist
Error:(12, 34) error: package org.openqa.selenium.remote does not exist
Error:(13, 38) error: package org.openqa.selenium.support.ui does not exist
Error:(14, 38) error: package org.openqa.selenium.support.ui does not exist
Error:(58, 6) error: cannot find symbol class Test
Error:(25, 9) error: cannot find symbol class DesiredCapabilities
Error:(25, 48) error: cannot find symbol class DesiredCapabilities
Error:(31, 36) error: cannot find symbol variable CapabilityType
Error:(34, 36) error: cannot find symbol variable CapabilityType
Error:(52, 22) error: cannot find symbol class RemoteWebDriver
Error:(63, 29) error: cannot find symbol variable By
Error:(66, 28) error: cannot find symbol variable By
please help me out
That means you have not imported all the jar files inside selenium folder
DeleteI have added all jar files
Deletecompile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile files('libs/cglib-nodep-3.2.4.jar')
compile files('libs/commons-codec-1.10.jar')
compile files('libs/commons-exec-1.3.jar')
compile files('libs/commons-io-2.5.jar')
compile files('libs/commons-lang3-3.5.jar')
compile files('libs/commons-logging-1.2.jar')
compile files('libs/cssparser-0.9.21.jar')
compile files('libs/gson-2.8.0.jar')
compile files('libs/guava-21.0.jar')
compile files('libs/hamcrest-core-1.3.jar')
compile files('libs/hamcrest-library-1.3.jar')
compile files('libs/htmlunit-2.24.jar')
compile files('libs/htmlunit-core-js-2.23.jar')
compile files('libs/htmlunit-driver-2.24.jar')
compile files('libs/httpclient-4.5.2.jar')
compile files('libs/httpcore-4.4.4.jar')
compile files('libs/httpmime-4.5.2.jar')
compile files('libs/java-client-5.0.0-BETA7.jar')
compile files('libs/javax.servlet-api-3.1.0.jar')
compile files('libs/jetty-io-9.4.1.v20170120.jar')
compile files('libs/jetty-util-9.4.1.v20170120.jar')
compile files('libs/jna-4.1.0.jar')
compile files('libs/jna-platform-4.1.0.jar')
compile files('libs/junit-4.12.jar')
compile files('libs/neko-htmlunit-2.24.jar')
compile files('libs/phantomjsdriver-1.4.0.jar')
compile files('libs/sac-1.3.jar')
compile files('libs/serializer-2.7.2.jar')
compile files('libs/websocket-api-9.2.20.v20161216.jar')
compile files('libs/websocket-client-9.2.20.v20161216.jar')
compile files('libs/websocket-common-9.2.20.v20161216.jar')
compile files('libs/xalan-2.7.2.jar')
compile files('libs/xercesImpl-2.11.0.jar')
compile files('libs/xml-apis-1.4.01.jar')
add multidexenabled true in build.gradle
ReplyDeletehow
ReplyDeleteError:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
ReplyDelete> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/openqa/selenium/internal/FindsByClassName.class
How do i fixed it? please help me
Hi Anuja,
ReplyDeleteI an facing below exception wile run sample code provided in blog.
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/HasInputDevices
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
on this line
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4724/wd/hub"), capabilities);
Could sure use some help on this. I've been trying to get it running for a couple of days.
DeleteI am getting this same error when I try to do a rebuild. The problem I think is that the HasInputDevices method is in org.openqa.selenium.interactions, but the the build seems to be looking for it in org.openqa.selenium. I am not sure why or how to fix it. Maybe it is a mismatch of the needed jar files?
DeleteCould sure use some help on this. I've been trying to get it running for a couple of days.
Hi
ReplyDeletegetting bellow error ,
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/collect/ImmutableMap;
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:57)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
after debugging I got that error is in
Method threw 'java.lang.NoClassDefFoundError' exception. Cannot evaluate org.openqa.selenium.remote.DesiredCapabilities.toString()
please replay ,
thanks in advance
Thanks
-Tapas
Hi there!
ReplyDeleteI am getting an exception of
java.lang.NullPointerException at com.example.eventhandling.appiumtestingexample.FirstTest.End.
Can you please help me with this?
Hi Anuja,
ReplyDeleteTried with your sample code. Build successful and calculator app opened and number 7 pressed , but it displays '1 test failed'
Process finished with exit code -1
Could you help me out where I went wrong.
Hello,
ReplyDeleteI am getting below error while executing the Appium script.Anyone can please suggest a solution or root cause
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/steadystate/css/parser/SACParserMessages_de.properties
File1: C:\Users\Admin\AndroidStudioProjects\AppiumProject\app\libs\cssparser-0.9.22.jar
File2: C:\Users\Admin\AndroidStudioProjects\AppiumProject\app\libs\selenium-server-standalone-3.4.0.jar
There is no duplicate file added in the gradle
Thank you
Sreejith
Can I get the libs?
ReplyDeletewhen i'm putting capabilities.setCapability it says can't resolve symbol setcapabilty. Please provide the jar files as i have already used the jar files selenium-remote-client 2.0a2.jar. please help me out from this issue
ReplyDeleteHi, you need to add all jar files in selenium folder including one outside lib folder
DeleteWhat we can use in place of node.exe and appium.js in mac and also need help to locate these
ReplyDeleteI wish there was something like this for mac users...i am completely lost when try edit my system environment variable.
ReplyDeleteHi Anuja,
ReplyDeleteI was trying calculator script and as you did in your video by not stating path for cal application in appium config...... as it was there in your mobile
i did same but server throws error and ends the server
following is the appium log
> Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4733 --app --platform-name Android --platform-version 23 --automation-name Appium --device-name "Moto" --log-no-color
> usage: main.js [-h] [-v] [--shell]
> [--localizable-strings-dir LOCALIZABLESTRINGSDIR] [--app APP]
> [--ipa IPA] [-U UDID] [-a ADDRESS] [-p PORT]
> [-ca CALLBACKADDRESS] [-cp CALLBACKPORT] [-bp BOOTSTRAPPORT]
> [-k] [-r BACKENDRETRIES] [--session-override] [--full-reset]
> [--no-reset] [-l] [-lt LAUNCHTIMEOUT] [-g LOG]
> [--log-level {info,info:debug,info:info,info:warn,info:error,warn,warn:debug,warn:info,warn:warn,warn:error,error,error:debug,error:info,error:warn,error:error,debug,debug:debug,debug:info,debug:warn,debug:error}]
> [--log-timestamp] [--local-timezone] [--log-no-colors]
> [-G WEBHOOK] [--native-instruments-lib]
> [--app-pkg ANDROIDPACKAGE] [--app-activity ANDROIDACTIVITY]
> [--app-wait-package ANDROIDWAITPACKAGE]
> [--app-wait-activity ANDROIDWAITACTIVITY]
> [--android-coverage ANDROIDCOVERAGE] [--avd AVD]
> [--avd-args AVDARGS]
> [--device-ready-timeout ANDROIDDEVICEREADYTIMEOUT] [--safari]
> [--device-name DEVICENAME] [--platform-name PLATFORMNAME]
> [--platform-version PLATFORMVERSION]
> [--automation-name AUTOMATIONNAME] [--browser-name BROWSERNAME]
> [--default-device] [--force-iphone] [--force-ipad]
> [--language LANGUAGE] [--locale LOCALE]
> [--calendar-format CALENDARFORMAT] [--orientation ORIENTATION]
> [--tracetemplate AUTOMATIONTRACETEMPLATEPATH]
> [--instruments INSTRUMENTSPATH] [--show-sim-log]
> [--show-ios-log] [--nodeconfig NODECONFIG] [-ra ROBOTADDRESS]
> [-rp ROBOTPORT] [--selendroid-port SELENDROIDPORT]
> [--chromedriver-port CHROMEDRIVERPORT]
> [--chromedriver-executable CHROMEDRIVEREXECUTABLE]
> [--use-keystore] [--keystore-path KEYSTOREPATH]
> [--keystore-password KEYSTOREPASSWORD] [--key-alias KEYALIAS]
> [--key-password KEYPASSWORD] [--show-config] [--no-perms-check]
> [--command-timeout DEFAULTCOMMANDTIMEOUT] [--keep-keychains]
> [--strict-caps] [--isolate-sim-device] [--tmp TMPDIR]
> [--trace-dir TRACEDIR] [--intent-action INTENTACTION]
> [--intent-category INTENTCATEGORY] [--intent-flags INTENTFLAGS]
> [--intent-args OPTIONALINTENTARGUMENTS]
> [--dont-stop-app-on-reset] [--debug-log-spacing]
> [--suppress-adb-kill-server] [--async-trace]
>
> main.js: error: argument "--app": Expected one argument. null
>
> Appium server process ended
Hello, I'm getting below errors.. what to do next?
ReplyDeleteError:(18, 5) error: cannot find symbol class WebDriver
Error:(21, 32) error: cannot find symbol class MalformedURLException
Error:(29, 36) error: cannot find symbol variable CapabilityType
Error:(32, 36) error: cannot find symbol variable CapabilityType
Error:(50, 22) error: cannot find symbol class RemoteWebDriver
Error:(51, 55) error: cannot find symbol variable TimeUnit
Error:(61, 29) error: cannot find symbol variable By
Error:(64, 28) error: cannot find symbol variable By
Error:(66, 54) error: cannot find symbol variable TimeUnit
i am unable to build my project after put this jar files.
ReplyDeleteHi Anuja,
ReplyDeleteI am getting below error while run my app.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK javax/servlet/LocalStrings_fr.properties
File1: D:\Paddy\Android\Project\Test2\app\libs\selenium-server-standalone-3.5.2.jar
File2: D:\Paddy\Android\Project\Test2\app\libs\selenium-server-standalone-3.5.2.jar
goog Post...More interesting articles here : Generation Enggelmundus Internet Marketing Tool here : Zeageat IM
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHI,
ReplyDeleteI am getting below error could you please help me on this.
error stating "Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Failed to create MD5 hash for file 'C:\Users\xyz\AndroidStudioProjects\AutomationAndroid\app\libs\commons-io-2.5.jar'.
build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:design:26.+'
testCompile 'junit:junit:4.12'
// testCompile 'org.assertj:assertj-core:2.0.0'
// testCompile 'org.testng:testng:6.9.10'
compile files('libs/cglib-nodep-3.2.4.jar')
compile files('libs/client-combined-3.5.3-nodeps.jar')
compile files('libs/commons-codec-1.10.jar')
compile files('libs/commons-exec-1.3.jar')
compile files('libs/commons-io-2.5.jar')
compile files('libs/commons-lang3-3.5.jar')
compile files('libs/commons-logging-1.2.jar')
compile files('libs/cssparser-0.9.23.jar')
compile files('libs/guava-23.0.jar')
compile files('libs/hamcrest-core-1.3.jar')
compile files('libs/htmlunit-2.27.jar')
compile files('libs/htmlunit-core-js-2.27.jar')
compile files('libs/htmlunit-driver-2.27.jar')
compile files('libs/httpclient-4.5.3.jar')
compile files('libs/httpcore-4.4.6.jar')
compile files('libs/httpmime-4.5.3.jar')
compile files('libs/java-client-5.0.0-BETA1.jar')
compile files('libs/javax.servlet-api-3.1.0.jar')
compile files('libs/jetty-client-9.4.5.v20170502.jar')
compile files('libs/jetty-http-9.4.5.v20170502.jar')
compile files('libs/jetty-io-9.4.5.v20170502.jar')
compile files('libs/jetty-util-9.4.5.v20170502.jar')
compile files('libs/jna-4.1.0.jar')
compile files('libs/jna-platform-4.1.0.jar')
compile files('libs/junit-4.12.jar')
compile files('libs/neko-htmlunit-2.27.jar')
compile files('libs/phantomjsdriver-1.4.0.jar')
compile files('libs/sac-1.3.jar')
compile files('libs/serializer-2.7.2.jar')
compile files('libs/websocket-api-9.4.5.v20170502.jar')
compile files('libs/websocket-client-9.4.5.v20170502.jar')
compile files('libs/websocket-common-9.4.5.v20170502.jar')
compile files('libs/xalan-2.7.2.jar')
compile files('libs/xercesImpl-2.11.0.jar')
compile files('libs/xml-apis-1.4.01.jar')
compile files('libs/apache-mime4j-0.6.jar')
compile files('libs/commons-collections-3.2.1.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/commons-lang3-3.4.jar')
compile files('libs/commons-logging-1.1.3.jar')
compile files('libs/commons-validator-1.4.1.jar')
compile files('libs/gson-2.3.1.jar')
compile files('libs/guava-18.0.jar')
compile files('libs/httpclient-4.4.1.jar')
compile files('libs/httpcore-4.4.1.jar')
compile files('libs/httpmime-4.4.1.jar')
compile files('libs/java-client-3.2.0.jar')
compile files('libs/selenium-java-2.47.1.jar')
compile files('libs/client-combined-3.4.0-nodeps.jar')
compile files('libs/java-client-5.0.3.jar')
}
Hi Anuja,
ReplyDeleteReally amazing blog.
Liked the way you have elaborated every steps. Just a quick question about the sample calculator project where I would be able to find to run this particular test case.
Would you be able to provide calculator project here.
Cheers,
Yesha
Can someone help me, i check all info about this error, but it didn't help me
ReplyDeleteI have this error:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
Hi I added the jars to lib folder and after rebuild of the project I am getting this errorFAILURE: Build failed with an exception.
ReplyDelete* What went wrong:
Execution failed for task ':app:transformClassesWithDesugarForDebug'.
Please help me resolve this
Hello Anuja,
ReplyDeleteGreat document, But I am still stuck to install and set up the application.
1- Android Studio 3.0
2- java-client-5.0.4.jar
3- selenium-java-3.6.0.zip
when re-build the app have following errors: any idea why?
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\myuser\AndroidStudioProjects\JavaTest\app\libs\guava-23.0.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/google/common/collect/Maps$AsMapView.class
Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\myuser\AndroidStudioProjects\JavaTest\app\libs\guava-23.0.jar
Appreciate your help in advance!
Hi I am getting error in the code which you have asked to copy paste
ReplyDeleteimport org.junit.After;
import org.junit.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class FirstTest {
WebDriver driver;
@Before
public void setUp() throws MalformedURLException {
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();
/* Set android deviceName desired capability. Set your device name. */
capabilities.setCapability("deviceName", "XT1562");
// Set BROWSER_NAME desired capability. It's Android in our case here.
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
// Set android VERSION desired capability. Set your mobile device's OS version.
capabilities.setCapability(CapabilityType.VERSION, "6.0.1");
// Set android platformName desired capability. It's Android in our case here.
capabilities.setCapability("platformName", "Android");
// Set android appPackage desired capability. It is
// com.android.calculator2 for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appPackage", "com.android.calculator2");
// Set android appActivity desired capability. It is
// com.android.calculator2.Calculator for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
// Created object of RemoteWebDriver will all set capabilities.
// Set appium server address and port number in URL string.
// It will launch calculator app in android device.
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
@Test
public void testFirstCalculator() {
// Click on DELETE/CLR button to clear result text box before running test.
driver.findElements(By.xpath("//android.widget.Button")).get(0).click();
// Click on number 2 button.
driver.findElement(By.name("7")).click();
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
}
@After
public void End() {
driver.quit();
}
}
I am unable to save.
Please help
Im getting this error java.lang.ClassCastException: org.openqa.selenium.remote.DesiredCapabilities cannot be cast to org.openqa.selenium.Capabilities
ReplyDeleteWhen I download selenium-java-3.8.1 it only contains following jar files
ReplyDeletebyte-buddy-1.7.5
commons-codec-1.10
commons-exec-1.3
commons-logging-1.2
gson-2.8.2
guava-23.0
httpclient-4.5.3
httpcore-4.4.6
Yes, this is what I see in the download. It seems it should be sufficient, but I can not seem to get past a rebuild due to the error above I've commented on:
ReplyDeleteException in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices
Has anyone found a solution to this? Is the author still monitoring these comments?
Hi Anuja,
ReplyDeleteI have followed the same steps as mentioned in your blog. But Im getting the below error:
java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;
at org.openqa.selenium.json.Json.(Json.java:47)
at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.constructMessage(HttpProfilerLogEntry.java:37)
at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.(HttpProfilerLogEntry.java:29)
....
java.lang.NullPointerException
at com.test.comcast.iristest.Login.End(Login.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Process finished with exit code -1
Can you please help?
Hi Anuja. Is this only for Unit Tests or can Systems Testing be done using this Environemnt ?
ReplyDeleteAnd can we test web applications with this set up?
ReplyDeleteHello,
ReplyDeleteThanks for the very use full and easy steps for mobile automation, with this i grow my 1 level up, and make many easy script for login and validations.
need to know something about UIAUTOMATOR 2, can you please help me to short out???
Thank You :)
Other Thing is how to manage wifi connection pro-grammatically ?
ReplyDeleteHi i am unable to run the build in my moto E mobile have the android version 5.1.
ReplyDeleteplease help me for setup.
it is giving me the 1error
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > More than one file was found with OS independent path 'META-INF/DEPENDENCIES
could you solve this?
DeleteHi i have followed all the steps as mentioned in your youtube tutorial, but my appium server doesnot show any logs as if its not even connected, my android studio doesnot give any errors but the test app (i gave the package and activity link for the playstore app) doesnot even invoke on my android device. Need help! thanks!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteYou are doing great job person like me, I am getting following error. Can you explain what I need to do:
org.testng.TestNGException:
Cannot find class in classpath: com.example.openstack.appiumapplication.FirstTest
at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
This is great initiative. Thanks for the article and answering questions.
ReplyDeleteAndroid Training In Chennai
Hi,
ReplyDeleteI am not able to run my test script. I got below error. please help me to solve this error.
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:59'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_152-release'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:435)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:94)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:102)
at com.example.version.appiumapplication.FirstTest.setUp(FirstTest.java:38)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
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 com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Caused by: java.lang.IllegalArgumentException: Source string may not be null
at org.apache.http.util.Args.notNull(Args.java:54)
at org.apache.http.entity.StringEntity.(StringEntity.java:65)
at org.apache.http.entity.StringEntity.(StringEntity.java:116)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:274)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:415)
... 32 more
Error: Type com.google.common.util.concurrent.Futures$FutureCombiner is referenced as an interface from `com.google.common.util.concurrent.Futures$8`.
ReplyDeleteHi Anuja, Thanks for posting the article. Its helpful.
ReplyDeleteI installed latest version of android studio 3.2.2. I have added dependencies to gradle. It is throwing below error. I am not able to find solution. Please help.
Errors:
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to completeCaused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: org.openqa.selenium.SearchContext.
Here is my Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.practice.myapplication"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/versions/9'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'org.seleniumhq.selenium:selenium-java:3.141.59'
implementation 'org.seleniumhq.selenium:selenium-remote-driver:3.141.59'
implementation 'org.testng:testng:6.14.3'
testImplementation 'org.testng:testng:6.14.3'
implementation 'io.appium:java-client:5.0.4'
}
I also installed latest version of android studio 3.2.2.
DeleteMy project is working properly
And here is mine. Hope this will help you.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.user.appiumapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/byte-buddy-1.8.15.jar')
implementation files('libs/commons-exec-1.3.jar')
implementation files('libs/guava-25.0-jre.jar')
implementation files('libs/java-client-7.0.0.jar')
implementation files('libs/okhttp-3.11.0.jar')
implementation files('libs/okio-1.14.0.jar')
implementation files('libs/client-combined-3.141.59.jar')
implementation files('libs/client-combined-3.141.59-sources.jar')
implementation files('libs/testng-6.14.3.jar')
}
I think you didn't add all .jar as library, watch my dependencies
DeleteThank you Anuja jain
ReplyDeleteIt's quite great tutorial.
Very helpful for me.
cheers
Newman
Hi,
ReplyDeleteI got some error while rebuild the project.
Error:Duplicate class org.openqa.selenium.SearchContext found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebDriver found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebDriver$ImeHandler found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebDriver$Navigation found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebDriver$Options found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebDriver$TargetLocator found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebDriver$Timeouts found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebDriver$Window found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.WebElement found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.internal.FindsByClassName found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.internal.FindsByCssSelector found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.internal.FindsById found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.internal.FindsByLinkText found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.internal.FindsByName found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.internal.FindsByTagName found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Duplicate class org.openqa.selenium.internal.FindsByXPath found in modules client-combined-3.141.59.jar (client-combined-3.141.59.jar) and java-client-7.0.0.jar (java-client-7.0.0.jar)
Hi Did u get any solution for this?
DeleteHi,
ReplyDeleteI am not able to run my test script. I got below error. please help me to solve this error.
Error: Program type already present: org.openqa.selenium.SearchContext.
thanks for sharing , love it , read it three time, thank u so much.
ReplyDeletewww.technewworld.in
How to Start A blog 2019
I like the helpful info you provide in your articles. Good luck with your next post...!
ReplyDeleteOracle Training in Chennai
Oracle course in Chennai
Tableau Training in Chennai
Spark Training in Chennai
Excel Training in Chennai
Primavera Training in Chennai
Appium Training in Chennai
Power BI Training in Chennai
Pega Training in Chennai
Oracle Training in T Nagar
Oracle Training in Porur
can u resolve Duplicate class org.openqa.selenium.WebDriver found in modules java-client-7.3.0.jar error in studio
Deletehow to exclude group:'io.appium', module: 'org.openqa.selenium' properly, I have Tried So many ways such as in packaging options, configurations, configurations.all, dependency exclusion none of these seems to be working, Hence Duplicate Class Issues remains While running Gradle Build with Selenium Java. Any Comments Please?!
ReplyDeletecan u share the solution?
Delete
ReplyDeleteGreat post. keep sharing such a worthy information
German Classes in Chennai
German Classes in Bangalore
German Classes in Coimbatore
German Classes in Madurai
German Language Course in Hyderabad
German Courses in Chennai
German Courses in Bangalore
German Courses in Coimbatore
German classes in marathahalli
Tally Course in Coimbatore
When iam doing setup of appium with android studio then these error occurs:
ReplyDelete1.Private interface methods are only supported starting with Android N (--min-api 24): java.lang.Object io.appium.java_client.functions.AppiumFunction.lambda$0(java.util.function.Function, java.lang.Object)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2.After adding these lines into the code then this error removes now this error shows
Default method desugaring of `io.appium.java_client.DefaultGenericMobileDriver` failed because its super class `org.openqa.selenium.remote.RemoteWebDriver` is missing
3.After adding selenium standlone jars then this error shows:
Duplicate class org.openqa.selenium.WebDriver found in modules java-client-7.3.0.jar (java-client-7.3.0.jar) and selenium-server-standalone-3.141.59.jar (selenium-server-standalone-3.141.59.jar)
Please help me to resolve this error fast
I am getting the same error, can you help
DeleteThis comment has been removed by the author.
DeleteHi!
DeleteA have the same error!
Please, can help me, if we khow how!
Hi there! I could have sworn I’ve visited this site before but after browsing through some of the posts I realized it’s new to me. Anyways, I’m certainly pleased I discovered it and I’ll be book-marking Webdevelop it and checking back often!
ReplyDeleteI owe my gratitude for sharing this wonderful blog post, which has helped me to succeed further in my career. Web Designing Course Training in Chennai | Web Designing Course Training in annanagar | Web Designing Course Training in omr | Web Designing Course Training in porur | Web Designing Course Training in tambaram | Web Designing Course Training in velachery
ReplyDeletegood content provided thank u so much oracle training in chennai
ReplyDeleteOh man! This blog is sick! How did you make it look like this !
ReplyDeleteOracle Cloud Administration training
Oracle Data Integrator online training
Oracle Data Integrator training
Oracle DBA online training
Oracle DBA training
Oracle Enterprise Manager online training
Oracle Enterprise Manager training
Oracle Exadata online training
Oracle Exadata training
Oracle fusion order management online training
If you think about it, even if you are not in the selling profession, you are selling every day. Are you a parent? Yep, you're in sales! Salesforce interview questions and answers
ReplyDeleteĐại lý vé máy bay Aivivu
ReplyDeletevé máy bay đi Mỹ hạng thương gia
ve may bay tet pacific airlines
vé máy bay đi Pháp khứ hồi
vé máy bay từ hải phòng đi hàn quốc
săn vé máy bay giá rẻ đi nhật bản
bay từ việt nam sang Anh mất bao lâu
xem vé máy bay giá rẻ
vé máy bay đi San Francisco
ve may bay di Los Angeles
combo nha trang giá rẻ
Major thanks for the article post.Really looking forward to read more. Much obliged.
ReplyDeletekiss day images
valentines day messages
This comment has been removed by the author.
ReplyDeleteBest blog! This is the best comprehensive content and Thank you so much...!
ReplyDeleteAutomation Anywhere Training in Chennai
Automation Anywhere Course in Chennai
Automation Anywhere Online Training
VMware Training in Chennai
Aivivu chuyên vé rẻ, tham khảo
ReplyDeletemua ve may bay di my
vé máy bay mỹ về việt nam
các chuyến bay từ anh về việt nam
vé máy bay từ pháp về việt nam