{"action":"created","issue":{"url":"https://api.github.com/repos/RobotiumTech/robotium/issues/329","labels_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/329/labels{/name}","comments_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/329/comments","events_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/329/events","html_url":"https://github.com/RobotiumTech/robotium/issues/329","id":101957847,"number":329,"title":"Preference objects not supported by Solo (e.g. ListPreference, CheckBoxPreference)","user":{"login":"renas","id":165541,"avatar_url":"https://avatars.githubusercontent.com/u/165541?v=3","gravatar_id":"","url":"https://api.github.com/users/renas","html_url":"https://github.com/renas","followers_url":"https://api.github.com/users/renas/followers","following_url":"https://api.github.com/users/renas/following{/other_user}","gists_url":"https://api.github.com/users/renas/gists{/gist_id}","starred_url":"https://api.github.com/users/renas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renas/subscriptions","organizations_url":"https://api.github.com/users/renas/orgs","repos_url":"https://api.github.com/users/renas/repos","events_url":"https://api.github.com/users/renas/events{/privacy}","received_events_url":"https://api.github.com/users/renas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RobotiumTech/robotium/labels/bug","name":"bug","color":"FFFFFF"},{"url":"https://api.github.com/repos/RobotiumTech/robotium/labels/imported","name":"imported","color":"FFFFFF"},{"url":"https://api.github.com/repos/RobotiumTech/robotium/labels/Priority-Medium","name":"Priority-Medium","color":"FFFFFF"},{"url":"https://api.github.com/repos/RobotiumTech/robotium/labels/wontfix","name":"wontfix","color":"FFFFFF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-19T17:49:38Z","updated_at":"2015-08-19T17:49:50Z","closed_at":null,"body":"_From [andrius....@gmail.com](https://code.google.com/u/108622049920371829661/) on April 19, 2012 03:50:33_\n\nFirst of all many thanks for such a great testing tool!\r\n\r\nI couldn't find any standard way to check state of objects descending from Preference, such as ListPreference, CheckBoxPreference, etc. It would be great if it would be possible to do such as solo.isCheckBoxPreferenceChecked() or solo.getListPreferenceValue()...\r\nBy researching into the ways of accomplishing mentioned tasks I came up with the following code:\r\n\r\n\tprivate Preference findPreference(String key) throws NullPointerException\r\n\t{\r\n\t\tArrayList<Activity> av = solo.getAllOpenedActivities(); \r\n\t\tfor (int i=0;i<av.size();i++)\r\n\t\t\tif (av.get(i) instanceof PreferenceActivity)\r\n\t\t\t{\r\n\t\t\t\tPreferenceActivity pa = (PreferenceActivity) av.get(i);\r\n\t\t\t\tPreference preference = pa.findPreference(key);\r\n\t\t\t\t\r\n\t\t\t\tif (preference == null)\r\n\t\t\t\t\tthrow new NullPointerException(\"Preference coult not be found: \" + key);\r\n\t\t\t\treturn preference;\r\n\t\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\tprivate ListPreference getListPreference(String key) throws NullPointerException\r\n\t{\r\n\t\tPreference preference = findPreference(key);\r\n\t\tif (preference instanceof ListPreference)\r\n\t\t\treturn (ListPreference) preference;\r\n\t\telse\r\n\t\t\tthrow new NullPointerException(\"Discovered Preference is not ListPreference\");\r\n\t}\r\n\tprivate CheckBoxPreference getCheckBoxPreference(String key) throws NullPointerException\r\n\t{\r\n\t\tPreference preference = findPreference(key);\r\n\t\tif (preference instanceof CheckBoxPreference)\r\n\t\t\treturn (CheckBoxPreference) preference;\r\n\t\telse\r\n\t\t\tthrow new NullPointerException(\"Discovered Preference is not CheckBoxPreference\");\r\n\t}\r\n\r\n\tprivate String getListPreferenceValue(String key)\r\n\t{\r\n\t\treturn getListPreference(key).getEntry().toString();\r\n\t}\r\n\r\n\r\nHope it is of any use to someone...\n\n_Original issue: http://code.google.com/p/robotium/issues/detail?id=250_"},"comment":{"url":"https://api.github.com/repos/RobotiumTech/robotium/issues/comments/132718537","html_url":"https://github.com/RobotiumTech/robotium/issues/329#issuecomment-132718537","issue_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/329","id":132718537,"user":{"login":"renas","id":165541,"avatar_url":"https://avatars.githubusercontent.com/u/165541?v=3","gravatar_id":"","url":"https://api.github.com/users/renas","html_url":"https://github.com/renas","followers_url":"https://api.github.com/users/renas/followers","following_url":"https://api.github.com/users/renas/following{/other_user}","gists_url":"https://api.github.com/users/renas/gists{/gist_id}","starred_url":"https://api.github.com/users/renas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renas/subscriptions","organizations_url":"https://api.github.com/users/renas/orgs","repos_url":"https://api.github.com/users/renas/repos","events_url":"https://api.github.com/users/renas/events{/privacy}","received_events_url":"https://api.github.com/users/renas/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T17:49:50Z","updated_at":"2015-08-19T17:49:50Z","body":"_From [snehalko...@gmail.com](https://code.google.com/u/114622551856357730737/) on June 18, 2014 07:40:51_\n\nI am also blocked to automate CheckBoxPreference. I am using Robotium 5.1. It will be good if you add support for this."}}