Sztucki
Sztucki

Reputation: 145

Creating a click listener for spinner in webview

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

Upvotes: 2

Views: 281

Answers (2)

Sztucki
Sztucki

Reputation: 145

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.

Upvotes: 0

stackr
stackr

Reputation: 2742

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
        }
    });

Upvotes: 1

Related Questions