Reuse script
Home › Forums › Ask Expert › Reuse script
- This topic has 8 replies, 3 voices, and was last updated 2 years, 4 months ago by Sergey ZAP.
-
AuthorPosts
-
May 5, 2022 at 5:17 pm #33033Marco MalziottiParticipant
Good evening
I have written a script for these two views (see attachment “HeaderMenu-web.jpg” and “RegistryFilled-web.jpg”).
Now these views are visible through a web view in an app.
Question: Can I reuse (with minor changes) the script written for the web also for the app as well?
Or do I have to re-edit all the screens and re-write another script for the same test case run by the app?
Thanks.Marco Malziotti
Attachments:May 5, 2022 at 5:18 pm #33034Marco MalziottiParticipantP.S. To use AUT replace the password in the .csv file with this one: https://ots.octotelematics.com/secret/2ao86iuutmctr6lxsz8oliev3gemxz0
May 5, 2022 at 10:04 pm #33068Sasha ZAPModeratorHello Marco,
In your attached script the Application object’ “regexpwndtitle” Property is set to the “CBPRO_PhoneModify.png - Foto” value, which means this Application object will be recognized only for the specific device it was captured from:
If you would like to enable the Application object to be recognized in any type of environment you can empty this Property value or set it as a parameter which its values will be changed based on some condition statement.
If you’ll do this change and if there is no significant difference between the Desktop and the mobile app’s UI, the script supposes to run in both platforms.
Please note, in mobile devices usually app pages objects are not fully visible as they are in the Desktop app’s pages (Usually due to screen size limitations), in such cases you can use methods such as “SwipeTo” orand “ScrollTo” to locate specific objects during runtime.
Hope this helps.
Thanks,
ZAPTEST TeamMay 6, 2022 at 11:55 am #33069Marco MalziottiParticipantThanks Sasha
I followed your advice and set the regexpwndclass and regexpwndtitle properties of the “CBPRO-it” application in the code that I want to reuse when running on Android.
In case of web execution everything is ok.
In the case of execution from mobile I have the same error as before. ZapTest recognizes lblEmail but not iconModify1 (line 81). Perhaps this is also a problem that can be solved with the Scalability parameter?
My goal, I repeat, is not to create a new application (like “Android”) in which to re-load and re-edit all the CBPRO screenshots viewed from a mobile device.
Thanks
Marco MalziottiMay 7, 2022 at 1:41 am #33137Sasha ZAPModeratorHello Marco,
It appears your website does not work when I’m answering your question, maybe the server is down.Regarding the “iconModify1” object, basically this is an image based object which means its recognition depends on its location upon the View (And the View depends on the screen’s resolution and size) – Please check the following video regarding the “Scalability” object property, which is one of the significant Image based object properties:
Also please check the following creating a cross-platform testing script tutorial video :
As you can see if there is a setting which is different in each platform you can use, for example, the following condition:
If Application(“CBPRO-it”).GetPlatformType = “android” Then
Application(“Android”).View(“RegistryFilled”).Object(“lblEmail”).Object(“iconModify1”).Click
Else
Application(“CBPRO-it”).View(“RegistryFilled”).Object(“lblEmail”).Object(“iconModify1”).Click
End If
Wait 4Hope this helps.
Thanks,
ZAPTEST TeamJuly 14, 2022 at 7:40 pm #33182Marco MalziottiParticipantHello Sasha,
Here is the new version of the script.
‘CBPRO-it’ Application did not evaluate the following parameters: regexpwndtitle, Width and Height.
Parameters regexpwndclass and regexpwndtitle are setted at runtime in case of execeution on mobile device (line 36 and 37).
‘iconModify1’ at line 81 are not recognized in execution on mobile device.
Please confirm that I am forced to create a new application (type “Android”) in which to reload and edit again all the CBPRO screenshots viewed from a mobile device.
What parameter can I change at runtime to avoid this?
Thank you.in the following links:
Mobile app Android: https://octospa-my.sharepoint.com/:u:/g/personal/m_malziotti_octotelematics_com/EWCJ5G5XUX1IpTSWM928o7IBiJjoDq4H-2T4Uue9knm73A?e=QTpVcxPassword to replace in “dt-cbpro-modify-email.csv” file (password field): https://ots.octotelematics.com/secret/ttjug2hhi0vyt3idpe7vj1fgf29gyt0
Both expires in 3 daysAttachments:July 15, 2022 at 9:57 pm #33183Sergey ZAPKeymasterHello Marco!
In line 81 you use Exist method against a relative object. In this case Exist applies to the parent object, which is the same as your line 80.
If relative position of object “iconModify1” is different on a mobile, you need to use a different view (mobile version).
Also you may not get correct reading for “GetPlatformName” in line 35. You need to use Launch method first.
Hope this helps.July 25, 2022 at 1:43 pm #33184Marco MalziottiParticipantThankyou SergeyP
you confirm that to allow execution on a PC of different resolution screen, is necessary to indicate in the application (CBPRO-it in my case):
regexpwndclass: ApplicationFrameWindows
regexpwndtitle:
width:
height:
?
And to click “iconModify1” set “Relative Object” = lblEmail and “Scalability” = “Location” in “iconModify1” object properties?
Thankyou
Marco MalziottiJuly 26, 2022 at 10:54 pm #33185Sergey ZAPKeymasterHi Marco!
You need to use Class (“regexpwndclass”) and Title (“regexpwndtitle”) properties to uniquely identify an AUT window. Width and Height don’t matter.
The value that you use (regexpwndclass = ApplicationFrameWindows) is good as long as ZAPTEST focuses on your application during the test run.
In order to run your test on a mobile device you need ZAPTEST to focus on ZAP Viewer, and you do it correctly by updating the Class and Title properties.
Your main challenge is that your Registry form looks very different on a mobile device, and you can not use same “iconModify1” object for both Desktop and Mobile tests. Scalability will not help here. You need to use a different view for the mobile version of this form. -
AuthorPosts
- You must be logged in to reply to this topic.