public void testSelectCostumeAndPlay() { solo.clickOnText(getActivity().getString(R.string.broadcast_nothing_selected)); solo.clickOnText(costumeName); assertTrue(costumeName + " is not selected in Spinner", solo.searchText(costumeName)); UiTestUtils.clickOnActionBar(solo, R.id.menu_start); solo.sleep(7000); solo.waitForActivity(StageActivity.class.getSimpleName()); solo.sleep(2000); Costume costume = ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).costume; assertEquals( "costume not set", costume.getImagePath(), costumeDataList.get(0).getAbsolutePath()); solo.goBack(); solo.goBack(); solo.waitForActivity(ScriptTabActivity.class.getSimpleName()); solo.clickOnText(costumeName); solo.clickOnText(costumeName2); assertTrue(costumeName2 + " is not selected in Spinner", solo.searchText(costumeName2)); UiTestUtils.clickOnActionBar(solo, R.id.menu_start); solo.waitForActivity(StageActivity.class.getSimpleName()); solo.sleep(2000); costume = ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).costume; assertEquals( "costume not set", costume.getImagePath(), costumeDataList.get(1).getAbsolutePath()); }
public void testSpinnerUpdatesRename() { String newName = "nameRenamed"; solo.clickOnText(lookName); assertTrue(lookName + " is not in Spinner", solo.searchText(lookName)); assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2)); solo.goBack(); solo.goBack(); solo.clickOnText(solo.getString(R.string.backgrounds)); clickOnContextMenuItem(lookName, solo.getString(R.string.rename)); solo.clearEditText(0); solo.enterText(0, newName); solo.clickOnButton(solo.getString(R.string.ok)); clickOnSpinnerItem(solo.getString(R.string.category_looks), solo.getString(R.string.scripts)); solo.clickOnText(newName); assertTrue(newName + " is not in Spinner", solo.searchText(newName)); assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2)); }
public void testAdapterUpdateInScriptActivity() { String costume1ImagePath = costumeDataList.get(0).getAbsolutePath(); String costume2ImagePath = costumeDataList.get(1).getAbsolutePath(); solo.clickOnText(getActivity().getString(R.string.broadcast_nothing_selected)); solo.clickOnText(costumeName); UiTestUtils.clickOnActionBar(solo, R.id.menu_start); solo.waitForActivity(StageActivity.class.getSimpleName()); String costumePath = ProjectManager.getInstance() .getCurrentSprite() .getCostumeDataList() .get(0) .getAbsolutePath(); assertEquals( "Wrong image shown in stage --> Problem with Adapter update in Script", costume1ImagePath, costumePath); solo.goBack(); solo.sleep(500); solo.goBack(); for (int i = 0; i < 5; i++) { selectCostume(costumeName2, costumeName, costume2ImagePath); selectCostume(costumeName, costumeName2, costume1ImagePath); } }
public void testSpinnerUpdates() { String spinnerNothingText = solo.getString(R.string.broadcast_nothing_selected); solo.clickOnText(spinnerNothingText); assertTrue(costumeName + " is not in Spinner", solo.searchText(costumeName)); assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2)); solo.goBack(); solo.clickOnText(getActivity().getString(R.string.backgrounds)); solo.clickOnButton(getActivity().getString(R.string.sound_delete)); solo.clickOnButton(getActivity().getString(R.string.ok)); solo.clickOnText(getActivity().getString(R.string.scripts)); solo.clickOnText(spinnerNothingText); assertFalse(costumeName + " is still in Spinner", solo.searchText(costumeName)); assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2)); }
public void selectCostume(String newCostume, String oldName, String costumeImagePath) { solo.clickOnText(oldName); solo.clickOnText(newCostume); UiTestUtils.clickOnActionBar(solo, R.id.menu_start); solo.sleep(5000); solo.waitForActivity(StageActivity.class.getSimpleName()); solo.sleep(2000); String costumePath = ProjectManager.getInstance().getCurrentSprite().costume.getImagePath(); assertEquals( "Wrong image shown in stage --> Problem with Adapter update in Script", costumeImagePath, costumePath); solo.goBack(); solo.goBack(); }
public final void selectMenuItem(String menuItemName) { // build the item name ready to be used String itemName = "^" + menuItemName + "$"; mActions.sendSpecialKey(Actions.SpecialKey.MENU); if (waitForText(itemName)) { mSolo.clickOnText(itemName); } else { // Older versions of Android have additional settings under "More", // including settings that newer versions have under "Tools." if (mSolo.searchText("(^More$|^Tools$)")) { mSolo.clickOnText("(^More$|^Tools$)"); } waitForText(itemName); mSolo.clickOnText(itemName); } }
public void clearPrivateData() { selectSettingsItem(StringHelper.PRIVACY_SECTION_LABEL, StringHelper.CLEAR_PRIVATE_DATA_LABEL); Actions.EventExpecter clearData = mActions.expectGeckoEvent("Sanitize:Finished"); mSolo.clickOnText("Clear data"); clearData.blockForEvent(); clearData.unregisterListener(); }
/** * The first walkthrough. Documented on the wiki. Starts on the login, ends up navigating to a * lesson after logging in. */ @Test public void testWalkthroughLoginToDashboardToCoursesToCourseToLesson() { // Login first EditText user = solo.getEditText(0); EditText pass = solo.getEditText(1); solo.typeText(user, "*****@*****.**"); solo.typeText(pass, "password"); solo.clickOnButton(solo.getString(com.huskysoft.eduki.R.string.login)); // Need to sleep to allow the activity to finish solo.sleep(8000); solo.assertCurrentActivity("Wrong activity", MainActivity.class); // Click on the all courses button solo.clickOnActionBarItem(com.huskysoft.eduki.R.id.action_courses); solo.sleep(1000); solo.assertCurrentActivity("Did not start the Course list Activity", CoursesListActivity.class); // Wait for the courses list to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.courseListView)); solo.sleep(1000); List<Course> courseList = ((CoursesListActivity) solo.getCurrentActivity()).getCourseList(); assertNotSame(courseList.size(), 0); solo.clickOnText("INTRODUCTION"); solo.assertCurrentActivity("Wrong activity", CourseActivity.class); // Wait for the course page to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.course_activity)); solo.sleep(1000); // Click a lesson, wait for it to appear List<Lesson> lessonList = ((CourseActivity) solo.getCurrentActivity()).getLessonList(); assertNotSame(lessonList.size(), 0); solo.clickOnText(lessonList.get(0).toString()); solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.lessonViewLayoutText)); solo.sleep(1000); String content = ((TextView) solo.getCurrentActivity() .findViewById(com.huskysoft.eduki.R.id.lessonViewLayoutText)) .getText() .toString(); assertFalse(content.equals("")); }
public void testSpinnerUpdatesRename() { String newName = "nameRenamed"; String spinnerNothingText = solo.getString(R.string.broadcast_nothing_selected); solo.clickOnText(spinnerNothingText); assertTrue(costumeName + " is not in Spinner", solo.searchText(costumeName)); assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2)); solo.goBack(); solo.clickOnText(getActivity().getString(R.string.backgrounds)); solo.clickOnView(solo.getView(R.id.costume_name)); solo.clearEditText(0); solo.enterText(0, newName); solo.clickOnButton(getActivity().getString(R.string.ok)); solo.sleep(500); solo.clickOnText(getActivity().getString(R.string.scripts)); solo.clickOnText(spinnerNothingText); assertTrue(newName + " is not in Spinner", solo.searchText(newName)); assertTrue(costumeName2 + " is not in Spinner", solo.searchText(costumeName2)); }
public List<String> getAllFormSections() { solo.clickOnText("Enquirer Details", 0); solo.waitForText("Tracing Information"); ListAdapter adapter = solo.getCurrentViews(ListView.class).get(0).getAdapter(); int totalCount = adapter.getCount(); List<String> formSections = new ArrayList<String>(); for (int i = 0; i < totalCount; i++) { formSections.add(adapter.getItem(i).toString()); } return formSections; }
public void testSpinnerUpdatesDelete() { solo.clickOnText(lookName); assertTrue(lookName + " is not in Spinner", solo.searchText(lookName)); assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2)); solo.goBack(); solo.goBack(); solo.clickOnText(solo.getString(R.string.backgrounds)); clickOnContextMenuItem(lookName, solo.getString(R.string.delete)); solo.clickOnButton(solo.getString(R.string.ok)); clickOnSpinnerItem(solo.getString(R.string.category_looks), solo.getString(R.string.scripts)); solo.clickOnText(lookName2); assertFalse(lookName + " is still in Spinner", solo.searchText(lookName)); assertTrue(lookName2 + " is not in Spinner", solo.searchText(lookName2)); }
/** * The second test, documented on the wiki. Starts on login. Does not login, instead navigates to * a course list and ends up at a quiz. */ @Test public void testWalkthroughLoginToCoursesListToCourseToQuiz() { // Need to sleep to allow the activity to finish solo.clickOnActionBarItem(com.huskysoft.eduki.R.id.action_courses); solo.sleep(1000); solo.assertCurrentActivity("Did not start the Course list Activity", CoursesListActivity.class); // Wait for the courses list to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.courseListView)); solo.sleep(1000); List<Course> courseList = ((CoursesListActivity) solo.getCurrentActivity()).getCourseList(); assertNotSame(courseList.size(), 0); solo.clickOnText("INTRODUCTION"); solo.assertCurrentActivity("Wrong activity", CourseActivity.class); // Wait for the course page to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.course_activity)); solo.sleep(1000); // Click a quiz, wait for it to appear List<Quiz> quizList = ((CourseActivity) solo.getCurrentActivity()).getQuizList(); assertNotSame(quizList.size(), 0); solo.clickOnText(quizList.get(0).toString()); solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.quizScrollView)); solo.sleep(2000); // Sleep to wait for the answers to populate List<RadioGroup> answersGroupList = ((QuizzesViewActivity) solo.getCurrentActivity()).getAnswerGroup(); for (int i = 0; i < answersGroupList.size(); i++) { RadioGroup current_rg = answersGroupList.get(i); List<RadioButton> list_rb = getRadioButtons(current_rg); assertTrue(list_rb.size() != 0); solo.clickOnView(list_rb.get(0)); // Answer "A" for everything solo.sleep(500); } solo.sleep(1000); solo.clickOnButton("SUBMIT"); solo.waitForActivity(QuizzesResultsActivity.class); solo.assertCurrentActivity("Wrong activity", QuizzesResultsActivity.class); }
public void testAddCourse() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { PreferenceManager.getDefaultSharedPreferences(getActivity()) .edit() .putBoolean("pref_use_android_calendar", true) .putString("pref_android_calendar_to_use", "1") .commit(); } UpdateService.setCrawlerToUse(SimpleMockCrawler.class); solo.clickOnView(getActivity().findViewById(R.id.add)); int oldsize = CourseContainer.instance().size(); solo.clickOnEditText(0); solo.enterText(0, "Course"); solo.clickOnEditText(0); solo.sendKey(Solo.ENTER); solo.waitForText("THE COURSE #2", 1, 5); solo.clickOnText("THE COURSE #2"); solo.waitForText("Courses", 1, 5); assertEquals(oldsize + 1, CourseContainer.instance().size()); assertTrue(solo.searchText("THE COURSE #2", 1, true)); Exam exam = CourseContainer.instance().get(CourseContainer.instance().size() - 1).exams.first(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { assertFalse("Exam of added course should have a created event", exam.event_id == -1); } oldsize = CourseContainer.instance().size(); solo.clickOnView(getActivity().findViewById(R.id.add)); solo.enterText(0, "Course"); solo.clickOnEditText(0); solo.sendKey(Solo.ENTER); solo.waitForText("THE COURSE #2", 1, 5); solo.clickOnText("THE COURSE #2"); assertEquals( "You should not be able to add the same course twice", oldsize, CourseContainer.instance().size()); solo.goBack(); solo.goBack(); }
public void test01ShouldShowMissingFileDialogIfNoFileTransferRequestAvailable() { openReceiveFileDialog(); solo.sleep(500); checkDialogMessage("Unable to find the specified file transfer request"); checkThatTheDialogIsInFront(); solo.clickOnText("OK"); // Close dialog solo.sleep(500); checkThatTheMainChatIsInFront(); checkThatNoFileTransferNotificationsAreActive(); }
@Override protected void setUp() throws Exception { super.setUp(); if (!NetTest.weAreOnline()) { getActivity().finish(); throw new AssertionFailedError( "Not online. Stopping this test since it depends on network connection."); } solo = new Solo(getInstrumentation(), getActivity()); // click on "Select game" button which should bring up RepoList (is // tested in Start) solo.waitForText( Util.getRessourceString( edu.bonn.mobilegaming.geoquest.R.string.start_button_game_list_text)); solo.clickOnText( Util.getRessourceString( edu.bonn.mobilegaming.geoquest.R.string.start_button_game_list_text)); // click on "Demos" to bring up GameListActivity on Demos repo: solo.waitForText("Demos"); solo.clickOnText("Demos"); }
/** * click on the input text * * @param params the text to click on * @return response with the status of the command */ private CommandResponse clickOnText(String[] params) { String command = "the command clickOnText"; CommandResponse result = new CommandResponse(); try { if (params.length == 1) { command += "(" + params[0] + ")"; solo.clickOnText(params[0]); } if (params.length == 2) { command += "(" + params[0] + "," + params[1] + ")"; solo.clickOnText(params[0], Integer.parseInt(params[1])); } if (params.length == 3) { command += "(" + params[0] + "," + params[1] + "," + params[2] + ")"; solo.clickOnText(params[0], Integer.parseInt(params[1]), Boolean.parseBoolean(params[2])); } result.setResponse(command + " : requested text was found and clicked on"); result.setSucceeded(true); } catch (Throwable e) { result = handleException(command, e); } return result; }
public void testCourseDetails() { Course course = CourseContainer.instance().get(0); course.exams = SimpleMockCrawler.createExams(course); solo.clickOnText("Course #0"); assertEquals(course.name, ((TextView) solo.getView(R.id.course_name, 0)).getText()); View exam_view; exam_view = solo.getView(R.id.exam_item, 0); assertEquals("Course #0", ((TextView) exam_view.findViewById(R.id.course_text)).getText()); solo.goBack(); }
public void selectFormSection(String formSectionName) { solo.waitForText("Save"); solo.clickOnView(solo.getCurrentViews(Spinner.class).get(0)); solo.waitForText(formSectionName); ListAdapter adapter = solo.getCurrentViews(ListView.class).get(0).getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { if (adapter.getItem(i).toString().equalsIgnoreCase(formSectionName)) { formPosition = i; break; } } solo.clickOnText(adapter.getItem(formPosition).toString()); solo.waitForText(formSectionName); solo.sleep(3); }
/** * After deleting the newly added podcast, it should not be displayed in the podcast list, and * should not be contained in the podcast DAO. */ public void testRemovePodcast() { Podcast p = insertPodcast(); while (solo.scrollDown()) ; solo.clickLongOnText(uuid); solo.clickOnText(getActivity().getString(at.ac.tuwien.detlef.R.string.delete_feed)); assertFalse( String.format("Deleted podcast %s should not be displayed in list", uuid), solo.searchText(uuid)); assertFalse( String.format("Deleted podcast %s should not be in DAO", uuid), dao.getPodcastById(p.getId()) != null); }
public void testSelectLookAndPlay() { assertTrue(lookName + " is not selected in Spinner", solo.isSpinnerTextSelected(lookName)); UiTestUtils.clickOnBottomBar(solo, R.id.button_play); solo.waitForActivity(StageActivity.class.getSimpleName()); solo.sleep(1000); Look look = ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).look; assertEquals("look not set", look.getImagePath(), lookDataList.get(0).getAbsolutePath()); solo.goBack(); solo.goBack(); solo.waitForActivity(ScriptActivity.class.getSimpleName()); solo.clickOnText(lookName); solo.clickOnText(lookName2); assertTrue(lookName2 + " is not selected in Spinner", solo.searchText(lookName2)); UiTestUtils.clickOnBottomBar(solo, R.id.button_play); solo.waitForActivity(StageActivity.class.getSimpleName()); solo.sleep(1000); look = ProjectManager.getInstance().getCurrentProject().getSpriteList().get(0).look; assertEquals("look not set", look.getImagePath(), lookDataList.get(1).getAbsolutePath()); }
/** Traverses the items in listItems in order in the menu. */ public void selectMenuItemByPath(String[] listItems) { int listLength = listItems.length; if (listLength > 0) { selectMenuItem(listItems[0]); } if (listLength > 1) { for (int i = 1; i < listLength; i++) { String itemName = "^" + listItems[i] + "$"; if (!waitForEnabledText(itemName)) { mSolo.scrollDown(); } mSolo.clickOnText(itemName); } } }
public void selectLook(String newLook, String oldName, String lookImagePath) { solo.clickOnText(oldName); solo.clickOnText(newLook); UiTestUtils.clickOnBottomBar(solo, R.id.button_play); solo.sleep(5000); solo.waitForActivity(StageActivity.class.getSimpleName()); solo.sleep(2000); String lookPath = ProjectManager.getInstance().getCurrentSprite().look.getImagePath(); assertEquals( "Wrong image shown in stage --> Problem with Adapter update in Script", lookImagePath, lookPath); solo.goBack(); solo.goBack(); }
public void testBrowseHouseTest() { try { Report.setTCNameLog(testName); // 如果打开应用后弹出“是否打开定位功能”的提示,选择“取消” if (solo.searchText("提示")) { solo.clickOnButton(1); } if (solo.searchText("刷新")) { solo.clickOnText("刷新"); } // Action.wait(solo, R.id.view_list_item_tv_title, count, "等待详细房源类表加载成功"); // Report.writeHTMLLog("安居客浏览房源用例", "附近页房源列表显示完全",Report.DONE,""); // 如果当前城市不是上海,就切换至上海 Action.switchCity(solo, "上海"); solo.clickOnText("搜索"); Action.scroolUpPage(solo, "浏览房源"); solo.clickOnText(bureau); solo.clickOnText(area); Report.writeHTMLLog("安居客浏览房源用例", "选中区域".concat(bureau).concat(area), Report.DONE, ""); Action.wait(solo, R.id.view_list_item_tv_title, count, "等待房源列表信息显示成功"); solo.clickOnView(solo.getView(R.id.view_list_item_tv_title)); solo.waitForText("收藏"); String houseTitle = (String) ((TextView) solo.getCurrentActivity().findViewById(R.id.prop_title)).getText(); Report.writeHTMLLog( "安居客浏览房源用例", "房源列表第一套房源标题为:" + houseTitle, "Done", Action.screenShot(solo)); // 点击返回按钮 Action.clickById(solo, R.id.detail_back_button, "点击返回按钮"); // 点击”更多"tab solo.clickOnText("我的"); solo.clickOnText("浏览记录"); solo.waitForText("清空"); solo.clickOnView(solo.getView(R.id.view_for_house_history_item_tv_title)); Report.writeHTMLLog("安居客浏览房源用例", "选中最近浏览的第一套房源", Report.DONE, ""); String browseHouseTitle = (String) ((TextView) solo.getCurrentActivity().findViewById(R.id.prop_title)).getText(); Report.writeHTMLLog("安居客浏览房源用例", "最近浏览的第一套房源标题为:" + browseHouseTitle, Report.DONE, ""); Boolean flag = Action.assertString(solo, "比较收藏房源标题是否匹配", houseTitle, browseHouseTitle); if (flag) { Report.writeHTMLLog("安居客浏览房源用例", "匹配成功", Report.PASS, ""); } else { Report.writeHTMLLog("安居客浏览房源用例", "匹配不成功用例失败", Report.FAIL, Action.screenShot(solo)); } // Report.seleniumReport(); } catch (Exception e) { String ps = Action.screenShot(solo); Report.writeHTMLLog("出现异常:" + e.getMessage(), "脚本停止", Report.FAIL, ps); // Report.seleniumReport(); } }
private void clickOnText(String text) { solo.clickOnText(text); }
private void rejectFileTransfer() { solo.clickOnText("Reject"); // Button in the popup dialog }
private void clickOnContextMenuItem(String lookName, String menuItemName) { solo.clickLongOnText(lookName); solo.waitForText(menuItemName); solo.clickOnText(menuItemName); }
private void clickOnSpinnerItem(String selectedSpinnerItem, String itemName) { solo.clickOnText(selectedSpinnerItem); solo.clickOnText(itemName); }
private void acceptFileTransfer() { solo.clickOnText("Accept"); // Button in the popup dialog }
public void navigateToCreatePage() { solo.clickOnText("Enquiry"); solo.waitForText("Enquiry details"); }
public void testDebug() { assertFalse(solo.searchText("Debug")); solo.sendKey(Solo.MENU); solo.clickOnText("Einstellungen"); solo.clickOnText("Debug-Modus"); solo.goBack(); assertTrue(solo.searchText("Debug")); solo.clickOnText("Debug"); assertTrue(solo.searchText("Debug SQLite")); solo.clickOnText("syncs"); solo.clickOnText("cafeterias"); solo.clickOnText("cafeterias_menus"); solo.clickOnText("feeds"); solo.clickOnText("feeds_items"); solo.clickOnText("lectures"); solo.clickOnText("lectures_items"); solo.clickOnText("links"); solo.clickOnText("events"); solo.clickOnText("news"); solo.clickOnText("time"); solo.clickOnText("locations"); solo.clickOnText("master"); solo.goBack(); assertTrue(solo.searchText("Hello World")); solo.sendKey(Solo.MENU); solo.clickOnText("Einstellungen"); solo.clickOnText("Debug-Modus"); solo.goBack(); assertFalse(solo.searchText("Debug")); }