2

I am currently creating an application that records a person actions on a webpage and saves them to a JSON file. so far I have been able to do this but I am having problems when recording actions for list-boxes within the web-view. I am then using the stored actions within the JSON file to creation an automation test within robotium.

When I click on the List-box it loads up a spinner with all of the items within the list-box. However, when I try to make a change it does not record it because it is in the spinner not the web-view. Also when playing it back through robotium it cannot find the list-box and causes an error despite it having an identifying attribute.

My question is how can I record the actions that change the value of the listbox and will I need to create a spinner listener to do this. If you need any more information or any code let me know and I shall edit this question. thanks in advance

Sztucki
  • 145
  • 1
  • 12

2 Answers2

1

If i understand correctly, you want to know what item is clicked. I would do it like this:

Spinner s = new Spinner(context);
    s.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // item at position "position" is clicked
        }
    });
stackr
  • 2,742
  • 27
  • 44
  • I do I also need to record all of the actions that are taken. such as selecting it and the pressing of the done button ect. As everything that is am doing has to be able to be replayed by robotium. I shall have a try this code thank you :) – Sztucki Jul 21 '14 at 09:52
  • Then i suggest putting OnClickListeners and OnItemClickListeners on all required elements. And then do the recording yourself or fill a ArrayList of HashMap with events so you can read those events later (if necessary) – stackr Jul 21 '14 at 09:56
  • ok thanks. Out of interest is there any way to do this in javascript. I currently have all of my other click, input text, and change listeners in there an it would be easier if I did it in there. – Sztucki Jul 21 '14 at 09:59
  • see this question+answer for more info on JavaScript on Android: http://stackoverflow.com/questions/10472839/using-javascript-in-android-webview – stackr Jul 21 '14 at 10:03
  • I have done all of that in my code the problem is that the spinner isnt strictly in the webview and cannot be identified in robotium. looks like I will have to do it in java. thanks for the help!! – Sztucki Jul 21 '14 at 10:06
  • If your question is answered, please mark the question as answered + (if you are satisfied with the way it has been answered) a +1 ;-) that way other people know where to get answers. – stackr Jul 21 '14 at 10:11
0

This problem cannot be fixed because it is an error that is in robotium. The issue is shown on this page: https://code.google.com/p/robotium/issues/detail?can=1&start=0&num=100&q=spinner&colspec=ID%20Type%20Stars%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=604

What I wanted to do was create a method in the JSON that would be able to be played through robotium. However it does not currently support the use of select boxes or spinners when they are clicked on and other things. I will now be finding a work around for the problem.

Sztucki
  • 145
  • 1
  • 12