Here is the error I keep getting if I run it:
FAILED: LoginFlow
java.lang.NullPointerException
at forAndDemo.LoginFlow(forAndDemo.java:56)
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:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Here is the error I get for this:
SKIPPED: LoginFlow
org.testng.TestNGException:
Method LoginFlow requires 1 parameters but 0 were supplied in the @Test annotation.
at org.testng.internal.Parameters.checkParameterTypes(Parameters.java:198)
at org.testng.internal.Parameters.createParameters(Parameters.java:134)
at org.testng.internal.Parameters.createParameters(Parameters.java:373)
at org.testng.internal.Parameters.handleParameters(Parameters.java:450)
at org.testng.internal.Invoker.handleParameters(Invoker.java:1383)
at org.testng.internal.Invoker.createParameters(Invoker.java:1075)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1180)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
@wreed since you answered me in the past a couple of times, any suggestions please?
Also if it helps…I tried running the test by not using any TestNG annotation…and just used a public static void main (string[] args). It ran just fine that time and executed the tests on the device.
also I am NOT using any xml files to run the tests.
So far it seems that it MAY have something to do with the setup of my jar files or env variables ? (or something along the lines). I’m on a MAC by the way.
My TestNG is pretty rusty as we don’t use it at my current job. I’m not sure why @Test doesn’t get the parameters for LoginFlow. Maybe try a TestNG forum?
@RamS thanks Ramdas, I was able to make it run. However, when I type ‘private AndroidDriver driver;’ I get a warning next to it that says "AndroidDriver is a raw type. References to generic type AndroidDrivershould be parameterized.
Could you also please tell me why I need here. I never figured why we need that mobileElement anywhere.
driver = new AndroidDriver(serveraddress, capabilities);
Also, do I need any parameters inside my @Test method, or does it need to say just ‘public void LoginFlow()’
@RamS thanks Ramdas. So we always need MobileElement parameter listed after AndroidDriver ?
Please see if you can answer this:
I already pasted a copy of my desired capabilities for you previously. The issue I have is right now: the app is on my desktop but in future I will have to run from Jenkins box which will pick up the tests from GitHub. Can you paste pice of code that I will need to have to accomplish that? This would mean that the app path will not be my desktop but something else.
@Styris
In my project, we build application using a Jenkins job. Also ,we build and run tests using different Jenkins job.
But we do have a internal framework which takes all capability values in the JSON format and builds respective driver for our test.
Similarly u can have a properties file to list all the desired capabilities and in your test class pull these values and build driver.
If u want to dynamically change any capability, you may want to have a script which overrides these values in properties file, before you trigger test compile and run.
@RamS I think I may have not put my question correctly…sorry about that. What I meant to say is that usually I Build the application using Xcode or Android Studio. I have it where the Build file is generated in a Build folder on my Desktop…hence in my capabilities the app path is directed to my desktop location.
How should I make that path or put that in the capabilities so that if a Jenkins box is running the Appium test it will pick up the path? (as I cannot keep it as my local desktop path). Also we check in stuff on GitHub.
You can not point to a desktop path from Jenkins Job.
But, you can refer to a server URL [ex: Another Jenkins job which has the application apk] in the capabilities.
Either you push the APK to a shared location which can be used by an URL or create a separate job to build your application apk and refer to that location.
@RamS so can you give me a one-line code exameple please (from the code I pasted above?)
I will be checking in the code into our repo on GitHub. Of course that will contain the src folder in there as well. Do you mean to say that i need to put the app in that folder ? In that case what will my code look like ?