How can identify element by using UIAutomatorviewer for mobile native app when we don't any unique attribute of the element - android-uiautomator

I am beginner in mobile automation testing and I want to learn how to identify element uniquely when element don't have any unique attribute.

The simples answer is "you can't". You have to identify it to the best of your capabilities.
If you previously know the app you are testing (most people are making tests specific for one app) then you can use the index property to your advantage.
If you don't you can only do an heuristic with as many properties you know about the object you are trying to identify.
Check uiAutomatorViewer (in sdk-folder/tools) to see the layout currently visible on your screen (UiAutomator sees exaclty the same).
Check UiObject and UiSelector classed to see which properties you can access.
If you have any more specific questions just say it :)

Related

Where exactly the data-cy or data-test-id attribute to the element to test can be added?

I am a beginner for the Cypress automation testing. I have gone through the good practice document for Cypress E2E where it suggests to use data-cy or data-test-id for element selection. This might be a simple and dumb question but I am really curious to know the answer from you guys. I tried googling but no luck.
Where exactly the data-cy or data-test-id attribute to the element to test can be added?
a. Do I have to checkout the code from the developers team, then add the attribute in there?
b. Can I use the invoke command in cypress (just like we can add/remove attr using invoke in jquery)?
c. Any other method?
If the option a. is your answer, then
what are the steps you follow?
Does the app code and testing code need to be in one project?
What hierarchy of element selection you follow?
(More info: I have frontend in Typescript and React, backend in sql, test project in cypress)
If data-cy or data-test-id attributes are not added to the elements in your project, you can not access the elements using these attributes.
Basically, it is a decision that team should take while developing front end application that all testable elements should have proper data-cy or data-test-id which gives more information about the element and it makes easy to write more stable and readable tests.
So I would suggest to discuss within a team to define strategy to add these attributes to the existing code and new code.
Read more about it at best practices for selecting elements in cypress

How to pass data across screens using mvvmcross

I have an mvvmcross xamarin project I am trying to figure out the best way I should approach sending data across screens for a particular situation.
My first screen is a search filter, it contains all kinds of criteria for the users to select for filtering results. The second screen is the results list screen.
I've seen numerous options for approaching this problem:
1) Use the Init method - The issue I'm having here is that when I pass custom objects, the values are always null/default. If I pass a string it works fine. If I could pass custom objects, I would either pass the EntityFilter or a List of Entities which is the results. I do have to query the entities on the filter page because what they select on one filter can affect others based on what entities remain. I have added the following to the AssemblyInfo.cs and it still doesn't work.
[assembly: InternalsVisibleTo("Cirrious.MvvmCross")]
2) Use Messaging. The problem here is that the result page isn't created when the filter is changed, so messaging won't work.
3) Use an in memory object. I created a results service that contains nothing but a public property of List of Entities. It's registered as lazy singleton in the IoC (as are all services). This method works and is my current solution. But it doesn't "feel" right. It feels like I'm doing something wrong or breaking best practices. Is this the way it should be done?
This is a fairly frequently asked question.
There's a recent question about using custom types for navigation at: Custom types in Navigation parameters in v3 - note that the original poster proposes one solution in their question there.
There are also several other questions around on this topic. The basic answer for all of these is that on many platforms navigation uses serialization techniques - e.g. Xaml Urls or Android Intents. Because of this, and because 'tombstoning' means that you can never be sure a "new" page will be in the same memory space as the "old" one, then by default MvvmCross insists on using simple serializable types for all ShowViewModel navigation.
This same reasoning for why navigation only allows simple serializable types is repeated all the way back to MvvmCross v1 - e.g. What is the best way to pass objects to "navigated to" viewmodel in MVVMCross?
The good news is that this topic is also getting some love in the official project docs - but these docs are still a bit of a work in progress - e.g. see https://github.com/MvvmCross/dev.mvvmcross.com/blob/master/_posts/1970-01-01-page-navigation.markdown

Prism, mapping region to a view

I'm quite new to Prism. I'm studying QuickStarts shipped with it as well as other examples on the net. Almost all of them make modules aware of what region their view(s) get dropped into. Typically, the method Initalize of a module has a line like the the following.
RegionManager.Regions["LeftRegion"].Add(fundView);
I feel quite uncomfortable with that. There's a similar discussion but I think that it should be the responsibility of the shell component to define such mapping. However, I cannot find any example of such approach and I'm not sure whether the bootstrapper is the right place to put such mapping in.
Is this approach completely wrong?
Nothing is completely wrong. But it makes no sense to have the shell/bootstrapper (that by design doesn't know anything about the application it will host) knows what view goes into which region.
Consider an application that can be extended by simply adding modules into a given folder. When you follow the approach that the module knows where it's views want to reside (the mapping is done in Initialize()), this is no problem. I designed my first Prism application that way.
But if your mapping is done in your shell you always have to update your shell (which is part of the base application, not any module) when you want to add another module. This runs contrary to the loosely coupling paradigm. Besides that you have to create one base application for every module constellation. And there are (2^number of modules) permutations you have to cover. That results in loosing your flexibility you gained by using Prism.

How do I create and process dynamic forms in ASP.NET MVC 3?

In an upcoming project, we will be creating forms for citizen's to fill out to start the process of applying for the requested license or permit. As one can imagine, a form tends to change often. I would prefer to plan this into the application to avoid making changes on a yearly/monthly/"the big boss want's it yesterday" basis.
My searching has shown me some examples based on the object passed to the view, but those would require coding changes. Others use XML, but never seems to go through the entire process from creating the from to storing the inputted data into the database. It isn't that I need hand holding the entire way; it's that this is something completely different for me and I want some guidance to get me in the right direction. I am thinking along the lines of how these survey sites (like SurveyMonkey) create dynamic polls.
Is there any tools, utilities, tutorials, or books that may cover this quite well?
I would imagine you would probably want to take advantage of Display / EditorTemplates. You would define an interface IQuestion or something, and then have a bunch of different form options that implement that interface. So your model would have a List<IQuestion>, and then for each question in the list, Html.EditorFor(item) or so.
Then some kind of standardized way of storing the answers into a table (perhaps a unique save / load method on IQuestion. That's my take anyways. You could define the questions via DB and then your models could have varying counts (and elements) in the List<IQuestion>. Just run a DB script (or some kind of admin page) and you could dynamically change the form displayed.

Virtualizing Data in Windows Phone 7: An example

In Windows Phone a ListBox support the virtualization of the data, that means it can only load the data needed and not everything. Peter Torr explains the interface you need to implement.
The short version is that you have to create both a method that return the position of an element and another one that return the element in a specific position. The problem is that the example of Peter Torr is rather dumb, he just return an object with the index as a name.
My question is: how do you actually implement this ?
My idea is to create one file that contains a list of an (integer) index and an (integer) id and a file for every object that contains the actual data. It doesn't seem a really elegant idea, but I can't think of anything better, can you ?
UPDATE
It seems that my question is inaccurate. When I say that the example of Peter Torr is "rather dumb" I am not saying that he has done anything wrong; his objective was simply to explain what interface you need to implement. The practical implementation will depend on the specific data.
What I am asking is what choices do I have to implement this ? Should I simply put the data on a web service and query it every time (with a local cache, of course), build a database, create a file the store the indexes and one for the data ? Is there a solution good enough in every case ? What are the downsides and upsides of every choice ?
The article you linked to includes a link to a downloadable project which demonstrates how to implement this.
What more are you after? The general idea is that the ListBox will call into your IList when it needs data. it will ask for an item at a specific index and you pass back an object. it then, presumably, calls ToString() on that object and displays the result in the list.
What that actual object is and where you pull it from is completely up to you. You might be using a really large array in memory. You might be pulling from IsolatedStorage or a web service. You could certainly use it to pull file info, but I don't suspect anyone has a ready-built IList implementation so that's the part that you will have to implement based on your specific project.

Resources