/** * Checks if a given text is selected in a given {@link Spinner} * * @param spinnerIndex the index of the spinner to check. 0 if only one spinner is available * @param text the text that is expected to be selected * @return true if the given text is selected in the given {@code Spinner} and false if it is not */ public boolean isSpinnerTextSelected(int spinnerIndex, String text) { waiter.waitForView(Spinner.class, spinnerIndex, false); ArrayList<Spinner> spinnerList = viewFetcher.getCurrentViews(Spinner.class); if (spinnerList.size() < spinnerIndex + 1) Assert.assertTrue("No spinner with index " + spinnerIndex + " is found! ", false); Spinner spinner = spinnerList.get(spinnerIndex); TextView textView = (TextView) spinner.getChildAt(spinner.getSelectedItemPosition()); if (textView.getText().equals(text)) return true; else return false; }