tvarchive / optimusTemplate

This is a cucumber jvm implementation template using the optimus mobile automation framework. If you like it, star it, help spread the word.
http://docs.testvagrant.com
66 stars 23 forks source link

IOS- processArguments with array of arguments is not accepted as capability #24

Closed sarathsp23 closed 6 years ago

sarathsp23 commented 6 years ago

When I pass processArguments with an array of argument, the same is not accepted as capability. Even though there is no exception thrown, but the process arguments are not passed to the application. Looking at the code ,seems like the only capabilities that are being set are either Boolean, String or Integer Below is how I am passing the processArguments

"appiumServerCapabilities": { "app": "OpalTravel.ipa", "platformName": "iOS", "platformVersion": "11.1.2", "deviceName": "iPhone 6", "noReset":true, "bundleID":"au.com.opal.travel", "autoDismissAlerts": true, "fullReset": false, "newCommandTimeout":60, "processArguments": { "args": [ "__OTA_VAR_ENVIRONMENT=TEST" ] } }

KrishnB commented 6 years ago

Thanks for pointing this out @sarathsp23 will look into this and update you. As you said we might be missing out on processing arrays.

KrishnB commented 6 years ago

@sarathsp23 this is resolved with the latest version of optimus. Please update your project optimus dependencies to below

Optimus Dependency

repositories {
    mavenCentral()
    jcenter()
}
dependencies {
    compile group: 'com.testvagrant', name: 'optimus', version: '3.0'
}

Optimus Gradle Plugin

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        mavenCentral()
    }
    dependencies {
        classpath "gradle.plugin.com.testvagrant.optimus:OptimusGradle:3.0"
    }

}
sarathsp23 commented 6 years ago

@KrishnB Hi Krishna, thanks for the fix, but unfortunately I have not been able to upgrade to the latest version due to the exceptions which I believe Asit has already raised.

KrishnB commented 6 years ago

Hi @sarathsp23 the issue was with duplicate scenario names in multiple feature files, this is resolved with the latest version 3.0.1 can you give it a try, below are the steps to update to latest version

1. Update optimusGradle version ==> 3.0.1
2. Optimus Dependency version ==> 3.0.1
3. Optimus services from 1.0 to ==> 2.0 ( this can be downloaded from here https://github.com/testvagrant/optimus-services/releases/tag/v2.0)
4. Kill running optimus services if any
5. Run it on a clean db state

Changes in this version

1. Added support for duplicate scenarios in multiple feature files which was causing build issues (but as a practice its good to avoid duplicate scenarios)
sarathsp23 commented 6 years ago

@KrishnB Hey , I updated the optimus and did not see an error, I will verify this bug and keep u update. Thanks Sarath

sarathsp23 commented 6 years ago

@KrishnB Hi, I tried with scenario which was present two seperate feature file, the tests in the original feature file got executed alright, but the second feature did not get executed at all. It threw the below error java.lang.IllegalStateException: Cannot parse content to class com.testvagrant.monitor.requests.Device because no content-type was present in the response and no default parser has been set. You can specify a default parser using e.g.: RestAssured.defaultParser = Parser.JSON;

or you can specify an explicit ObjectMapper using as(class com.testvagrant.monitor.requests.Device, ); at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 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.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83) at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247) at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl$_as_closure3.doCall(RestAssuredResponseOptionsGroovyImpl.groovy:219) at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl$_as_closure3.doCall(RestAssuredResponseOptionsGroovyImpl.groovy) 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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.findContentType(RestAssuredResponseOptionsGroovyImpl.groovy:482) 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.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.as(RestAssuredResponseOptionsGroovyImpl.groovy:218) at io.restassured.internal.RestAssuredResponseOptionsImpl.as(RestAssuredResponseOptionsImpl.java:164) at com.testvagrant.monitor.clients.DevicesClient.getDevice(DevicesClient.java:50) at com.testvagrant.monitor.services.DevicesServiceImpl.updateFirstAvailableDeviceToEngaged(DevicesServiceImpl.java:38) at com.testvagrant.optimus.device.DeviceFinder.getAvailableDeviceAndUpdateToEngaged(DeviceFinder.java:56) at com.testvagrant.optimus.parser.OptimusConfigParser.allocateDevicesForCurrentScenario(OptimusConfigParser.java:151) at com.testvagrant.optimus.device.OptimusController.registerSmartBOTs(OptimusController.java:152) at steps.StartingSteps.setUp(StartingSteps.java:31) 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 cucumber.runtime.Utils$1.call(Utils.java:32) at cucumber.runtime.Timeout.timeout(Timeout.java:16) at cucumber.runtime.Utils.invoke(Utils.java:26) at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60) at cucumber.runtime.HookDefinitionMatch.runStep(HookDefinitionMatch.java:17) at cucumber.runner.UnskipableStep.executeStep(UnskipableStep.java:22) at cucumber.api.TestStep.run(TestStep.java:83) at cucumber.api.TestCase.run(TestCase.java:58) at cucumber.runner.Runner.runPickle(Runner.java:80) at cucumber.runtime.Runtime.runFeature(Runtime.java:119) at cucumber.runtime.Runtime.run(Runtime.java:104) at cucumber.api.cli.Main.run(Main.java:36) at cucumber.api.cli.Main.main(Main.java:18)

KrishnB commented 6 years ago

Hi @sarathsp23 can you please verify if your scenarios collection in db is updated with the field featureFileName. If not you can try on a clean db state with optimus-services 2.0

sarathsp23 commented 6 years ago

@KrishnB I am not sure if I did correctly, but I tried by dropping the db . If that is not how it is supposed to be done. Can you please let me know the steps to following to clean the db state wth optimus 2.0?

KrishnB commented 6 years ago

Hi @sarathsp23 these are the below steps as I mentioned before

1. Update optimusGradle version ==> 3.0.1
2. Optimus Dependency version ==> 3.0.1
3. Optimus services from 1.0 to ==> 2.0 ( this can be downloaded from here https://github.com/testvagrant/optimus-services/releases/tag/v2.0)
4. Kill running optimus services if any
5. Run it on a clean db state

I guess you will have to recheck on step4 I think there are old services running on 8090 or 8080 you can check it using lsof -i:<portnumber> and kill the existing services

sarathsp23 commented 6 years ago

I keep getting this exception below Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "timestamp" (class com.testvagrant.monitor.responses.BuildsResponse), not marked as ignorable (2 known properties: "links", "content"]) at [Source: (String)"{ "timestamp" : "2018-07-23T23:36:24.058+0000", "status" : 500, "error" : "Internal Server Error", "message" : "Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]; nested exception is com.mongodb.MongoTimeoutException: Ti"[truncated 395 chars]; line: 2, column: 18] (through reference chain: com.testvagrant.monitor.responses.BuildsResponse["timestamp"]) at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:60) at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:822) at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1152) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1567) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1545) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3030) at com.fasterxml.jackson.databind.ObjectMapper$readValue$2.call(Unknown Source) at io.restassured.internal.path.json.mapping.JsonPathJackson2ObjectDeserializer.deserialize(JsonPathJackson2ObjectDeserializer.groovy:45) at io.restassured.path.json.mapping.JsonPathObjectDeserializer$deserialize.call(Unknown Source) at io.restassured.internal.mapping.Jackson2Mapper.deserialize(Jackson2Mapper.groovy:58) at io.restassured.mapper.ObjectMapper$deserialize$0.call(Unknown Source) at io.restassured.internal.mapping.ObjectMapping.parseWithJackson2(ObjectMapping.groovy:202) at io.restassured.internal.mapping.ObjectMapping$parseWithJackson2$1.callStatic(Unknown Source) at io.restassured.internal.mapping.ObjectMapping.deserialize(ObjectMapping.groovy:55) at io.restassured.internal.mapping.ObjectMapping$deserialize$0.call(Unknown Source) at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.as(RestAssuredResponseOptionsGroovyImpl.groovy:222) at io.restassured.internal.RestAssuredResponseOptionsImpl.as(RestAssuredResponseOptionsImpl.java:164) at com.testvagrant.monitor.clients.BuildsClient.getLatestBuildId(BuildsClient.java:40) at com.testvagrant.monitor.services.OptimusServiceImpl.getLatestBuild(OptimusServiceImpl.java:10) at com.testvagrant.monitor.services.DevicesServiceImpl.insertDeviceList(DevicesServiceImpl.java:30) at com.testvagrant.optimus.register.DeviceRegistrar.setUpDevices(DeviceRegistrar.java:31) at com.testvagrant.optimus.OptimusMain.setup(OptimusMain.java:38) at com.testvagrant.optimus.OptimusMain.main(OptimusMain.java:33)

KrishnB commented 6 years ago

Hi @sarathsp23, log says mongodb is not running. You will have to start manually if you are running it locally using mongod.