Closed suhasini-Ravi closed 4 years ago
For Optimus, the root context is app name so if your app names say app-android, and app-ios, then you can structure your elements as
Hey Krishna, Thank you for the reply... I have created the below json file under resources - >elements and named it as homescreen.json
{ "apps": [ { "app": "wmt_dev.ipa", "elements": [ { "name": "lo_payments_btn", "screen": "homescreen", "identifier": "id", "value": "fwo_header_label_action", "waitFor": "visibility" } ] },
{
"app": "wmt_dev_unhardened.apk",
"elements": [
{
"name": "lo_payments_btn",
"screen": "homescreen",
"identifier": "id",
"value": "i_rtl_action",
"waitFor": "visibility"
}
]
}
] }
my feature file has the line > When Iam on homescreen screen taps on lo_payments_btn
when I run the script, it is throwing the below error.
com.testvagrant.stepdefs.exceptions.ElementsFolderNotFoundException: Cannot find elements folder for project banking-dev. Elements should be created under respective app folders.
When Iam on homescreen screen taps on lo_payments_btn # GenericSteps.consumerOnScreenPerformsActionOnElement(String,String,String,String) com.testvagrant.stepdefs.exceptions.ElementsFolderNotFoundException: Cannot find elements folder for project banking-dev. Elements should be created under respective app folders. at com.testvagrant.stepdefs.finder.ElementStore.getElementsFileRelativePath(ElementStore.java:128) at com.testvagrant.stepdefs.finder.ElementStore.getFileName(ElementStore.java:84) at com.testvagrant.stepdefs.finder.ElementStore.read(ElementStore.java:36) at com.testvagrant.stepdefs.finder.OptimusElementFinder.getAppElement(OptimusElementFinder.java:55) at com.testvagrant.stepdefs.finder.OptimusElementFinder.findWebElement(OptimusElementFinder.java:39) at com.testvagrant.stepdefs.core.Tapster.serve(Tapster.java:84) at steps.GenericSteps.consumerOnScreenPerformsActionOnElement(GenericSteps.java:31) at ✽.Iam on homescreen screen taps on lo_payments_btn(/Order.feature:15)
Hey, your JSON format is invalid. app
is an invalid key in elements file. App name has to be a directory name as mentioned in the previous comment.
Hey, thanks again...
I changed the directory structure as mentioned above and also the json file which looks like below nd named it as homescreen.json
{ "elements": [ { "name": "lo_payments_btn", "screen": "homescreen", "identifier": "id", "value": "home_header_label_action", "waitFor": "visibility" } ] }
Getting the below error when i try to run.
java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:135)
at utils.OptimusImpl.findBOTFor(OptimusImpl.java:21)
at steps.BaseSteps.getSmartBOTBelongingTo(BaseSteps.java:22)
at steps.BaseSteps.getDriverInstanceFor(BaseSteps.java:18)
at steps.GenericSteps.consumerOnScreenPerformsActionOnElement(GenericSteps.java:26)
The same is getting passed when I run it normally by using page factory and with the custom feature.
Can you update the following file /src/test/resources/META-INF/Optimus.yaml
. Default extension is elements
please update it to json
Even after upadating the Optimus.yaml file, getting the same above issue.
Could you please help on this
Sure, please share us below
@Order_feature Feature: General test cases for login page
Background: Given I am on onaboarding screen And I click on Let's go on onboarding screen When I enter valid credentials And I click on sign in Then I should see the finance overview screen
@Order_Create_order_LongReceiverName_AlertMessage Scenario: Created a order with long receiver name, an alert message is displayed
When Iam on OverviewPage screen taps on lo_payments_btn
{ "executionDetails": { "appium_js_path": "/usr/local/bin/appium", "appium_node_path": "/usr/local/bin/node" }, "testFeed": [ { "belongsTo": "coreframework", "runsOn": "device", "appDir": "app", "nativeApp":true, "optimusDesiredCapabilities": { "appiumServerCapabilities": { "app": "wmt-Dev.ipa", "platformName": "iOS", "automationName": "XcuiTest" }, "iOSOnlyCapabilities": { "launchTimeout": 3000, "useNewWDA": false, "showXcodeLog": false, "clearSystemFiles": true } }, "deviceState": { "captureVideo": false } } ] }
a) mongod b) ./gradlew runFragmentation -DtestFeed=CoreBDDiOSParallel -Dtags=@Order_feature
Kindly, let me know in need of any other info
Looks like a configuration issue, suggest you go through this link for more details. http://docs.testvagrant.com/genericsteps.
Coming to the current issue; In your step, you have mentioned it as When Iam on OverviewPage screen taps on lo_payments_btn
, where Iam
points to the appium driver which is the belongsTo
field in your testfeed.
"testFeed": [
{
"belongsTo": "coreframework",
...
As there is a name mismatch Optimus cannot execute the step.
Solution:
Change your belongsTo
field to Iam
or some meaningful name as per your domain and update your step accordingly.
Eg:
"testFeed": [
{
"belongsTo": "user",
...
Step
When user on OverviewPage screen taps on lo_payments_btn
Changed the belongsTo field and now getting the different error as below.
When user on OverviewPage screen tap on lo_payments_btn # GenericSteps.consumerOnScreenPerformsActionOnElement(String,String,String,String) java.lang.NullPointerException at com.testvagrant.stepdefs.finder.ElementStore.lambda$find$0(ElementStore.java:44) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1359) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at com.testvagrant.stepdefs.finder.ElementStore.find(ElementStore.java:44) at com.testvagrant.stepdefs.finder.OptimusElementFinder.getAppElement(OptimusElementFinder.java:55) at com.testvagrant.stepdefs.finder.OptimusElementFinder.findWebElement(OptimusElementFinder.java:39) at com.testvagrant.stepdefs.core.Tapster.serve(Tapster.java:84) at steps.GenericSteps.consumerOnScreenPerformsActionOnElement(GenericSteps.java:31)
this conversation is getting out of scope for this issue. You can join our slack group for any queries https://join.slack.com/t/optimuscloud/shared_invite/enQtNjE2NTEwNjMyNjQ0LWM5NWYzNzQwMmNhNzk0NzVhZTliMGZiYzYxNzljZDNjYTVhZWE1ZTU1ODEyMzJhZDZlMjE1OGUzMzUyNzI3MzA
happy to help
Closing the issue.
Thank you again for resolving the issue
Hi team,
In my project, the application has both iOS and Android platforms, for the same app. Can you please let me know on how to have the elements JSON file for both iOS and android elements.