Index: lams_common/test/java/org/lamsfoundation/lams/selenium/AbstractSeleniumTestCase.java =================================================================== diff -u --- lams_common/test/java/org/lamsfoundation/lams/selenium/AbstractSeleniumTestCase.java (revision 0) +++ lams_common/test/java/org/lamsfoundation/lams/selenium/AbstractSeleniumTestCase.java (revision 56fb29e56260a46b9cc90c273018a01f93361631) @@ -0,0 +1,597 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.selenium; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.LearningDesign; +import org.lamsfoundation.lams.learningdesign.ToolActivity; +import org.lamsfoundation.lams.learningdesign.dao.hibernate.ActivityDAO; +import org.lamsfoundation.lams.learningdesign.dao.hibernate.LearningDesignDAO; +import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.dao.hibernate.LessonDAO; +import org.lamsfoundation.lams.tool.Tool; +import org.lamsfoundation.lams.tool.dao.hibernate.ToolDAO; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.Workspace; +import org.lamsfoundation.lams.usermanagement.service.UserManagementService; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import com.thoughtworks.selenium.HttpCommandProcessor; +import com.thoughtworks.selenium.SeleneseTestCase; + +public abstract class AbstractSeleniumTestCase extends SeleneseTestCase { + + protected ToolDAO toolDAO; + protected ActivityDAO activityDAO; + protected UserManagementService userManagementService; + protected LessonDAO lessonDAO; + protected LearningDesignDAO learningDesignDAO; + + private static final String TIMEOUT = "20000"; + + private static final String[] contextConfigLocation = new String[] { + "org/lamsfoundation/lams/localCommonContext.xml", + "org/lamsfoundation/lams/lesson/lessonApplicationContext.xml", + "org/lamsfoundation/lams/toolApplicationContext.xml", + }; + + // name of the learning design. we receive it from the subclass initially. + // but then it might be changed if LD with the same name already exists + private String learningDesignName; + + public void setUp() throws Exception { + ApplicationContext context = new ClassPathXmlApplicationContext(contextConfigLocation); + toolDAO = (ToolDAO) context.getBean("toolDAO"); + activityDAO = (ActivityDAO) context.getBean("activityDAO"); + userManagementService = (UserManagementService) context.getBean("userManagementService"); + lessonDAO = (LessonDAO) context.getBean("lessonDAO"); + learningDesignDAO = (LearningDesignDAO) context.getBean("learningDesignDAO"); + learningDesignName = getLearningDesignName(); + + HttpCommandProcessor proc = new HttpCommandProcessor( + TestFrameworkConstants.SERVER_HOST, + TestFrameworkConstants.SERVER_PORT, + TestFrameworkConstants.BROWSER, + TestFrameworkConstants.WEB_APP_HOST + + TestFrameworkConstants.WEB_APP_DIR); + selenium = new DefaultSeleniumFlex(proc); + selenium.start(); + //do not reduce this parameter as Selenium might start working wrong + selenium.setSpeed("400"); + } + + public void tearDown() throws Exception { + try { + super.tearDown(); + } finally { + if (selenium != null) { + selenium.stop(); + selenium = null; + } + } + } + + /** + * Our main test class. Currently it tests authoring, learning and + * monitoring sequentially one-by-one. Also it relies on the fact that you + * store new LD in authoring (otherwise you should reimplement this method). + * + * @throws Exception + */ + public void testEntireTool() throws Exception { + loginToLams(); + + //Authoring part + Map contentDetails = setUpAuthoring(); + authoringTest(); + storeLearningDesign(contentDetails); + + createNewLesson(); + + //Learning part + learningTest(); + + //Monitoring part + openToolMonitor(); + monitoringTest(); + closeToolMonitor(); + } + + /** + * Returns tool's signature. This method should be overridden by all subclasses. + * + * @return tool's signature + */ + protected abstract String getToolSignature(); + + /** + * Returns the name of learning design as it should be saved. + * Should be overridden by all subclasses. + * + * @return name of learning design + */ + protected abstract String getLearningDesignName(); + + /** + * Tests tool authoring. + * Should be overridden by all subclasses. + */ + protected abstract void authoringTest() throws Exception; + + /** + * Tests tool learning. Always should begin with setUpLearning() and end up with tearDownLearning() methods. + * Should be overridden by all subclasses. + */ + protected abstract void learningTest() throws Exception; + + /** + * Tests tool monitoring. + * Should be overridden by all subclasses. + */ + protected abstract void monitoringTest() throws Exception; + + /** + * Opens up all authoring windows. Should be done before testing tool's + * authoring. + * + * @return Map containing contentFolderID and toolContentID + * @throws Exception + */ + protected Map setUpAuthoring() throws Exception { + // open authoring canvas + selenium.click("//div[@id='header-my-courses']//div[@class='tab-middle-highlight']/a"); + selenium.waitForPopUp("aWindow", "10000"); + + Integer userID = userManagementService.getUserByLogin(TestFrameworkConstants.USER_LOGIN).getUserId(); + String createUniqueContentFolderUrl = TestFrameworkConstants.WEB_APP_DIR + + "authoring/author.do?method=createUniqueContentFolder&userID=" + + userID; + final String createUniqueContentFolderId = "createUniqueContentFolderId"; + selenium.openWindow(createUniqueContentFolderUrl, createUniqueContentFolderId); + selenium.waitForPopUp(createUniqueContentFolderId, "10000"); + selenium.selectWindow(createUniqueContentFolderId); + String wddxPacket = selenium.getEval("this.browserbot.getDocument().getElementsByTagName('body')[0].innerHTML"); + final String contentFolderID = this.extractFolderIDFromWDDXPacket(wddxPacket); + selenium.close(); + selenium.selectWindow(null); + + Tool tool = toolDAO.getToolBySignature(getToolSignature()); + String getToolContentUrl = TestFrameworkConstants.WEB_APP_DIR + + "authoring/author.do?method=getToolContentID&toolID=" + + tool.getToolId(); + final String getToolContentId = "getToolContentId"; + selenium.openWindow(getToolContentUrl, getToolContentId); + selenium.waitForPopUp(getToolContentId, "10000"); + selenium.selectWindow(getToolContentId); + wddxPacket = selenium.getEval("this.browserbot.getDocument().getElementsByTagName('body')[0].innerHTML"); + final String toolContentID = this.extractToolContentIDFromWDDXPacket(wddxPacket); + selenium.close(); + selenium.selectWindow(null); + + String openToolUrl = TestFrameworkConstants.WEB_APP_DIR + tool.getAuthorUrl() + "?mode=author" + + "&toolContentID=" + toolContentID + "&contentFolderID=" + + contentFolderID; + final String openToolId = "openToolId"; + selenium.openWindow(openToolUrl.toString(), openToolId); + selenium.waitForPopUp(openToolId, TIMEOUT); + selenium.selectWindow(openToolId); + + return new HashMap() {{ + put("contentFolderID", "contentFolderID"); + put("toolContentID", toolContentID); + }}; + } + + /** + * Stores learning design. Uses getLearningDesignName() as a new design name. + */ + protected void storeLearningDesign(Map contentDetails) { + //closes tool authoring screen + selenium.click("//span[@class='okIcon']"); + selenium.waitForPageToLoad("10000"); + selenium.click("//span[@class='close']"); + + //closes Flash authoring screen + selenium.selectWindow("aWindow"); + selenium.close(); + selenium.selectWindow(null); + + final String storeLearningDesignUrl = TestFrameworkConstants.WEB_APP_DIR + "servlet/authoring/storeLearningDesignDetails"; + String designDetails = constructWddxDesign(contentDetails); + //if at some point in the future we decide to use Prototype instead of jQUery we should use this command +// selenium.runScript("var options = { " + "method:\"post\", " + "postBody:\"" + designDetails + "\" " + "};" +// + "new Ajax.Request(\"" + storeLearningDesignUrl + "\",options);"); + selenium.runScript("$.post(\"" + storeLearningDesignUrl + "\", \"" + designDetails + "\");"); + } + + /** + * Beware this method might work wrong (due to the CloudWizard's hidden/visible root element) + * + * @throws Exception + */ + protected void createNewLesson() throws Exception { + Long lastCreatedLessonId = getLastCreatedLessonId(true); + DefaultSeleniumFlex flexSelenium = (DefaultSeleniumFlex) selenium; + + User user = userManagementService.getUserByLogin(TestFrameworkConstants.USER_LOGIN); + Workspace workspace = (Workspace) activityDAO.find(Workspace.class, user.getWorkspace().getWorkspaceId()); + Integer workspaceFolderID = workspace.getDefaultFolder().getWorkspaceFolderId(); + List titles = learningDesignDAO.getLearningDesignTitlesByWorkspaceFolder(workspaceFolderID); + assertTrue("There is no stored learning design", titles.size() > 0); + Collections.sort(titles, String.CASE_INSENSITIVE_ORDER); + int count = 1; + for (String title : titles) { + if (title.equals(learningDesignName)) { + break; + } + count++; + } + assertTrue("There isn't learning design with name" + learningDesignName,count <= titles.size()); + + flexSelenium.click("link=Add Lesson"); + Thread.sleep(6000); + // flexObjId is now setted to "cloudWizard" by default, change this if + // you want to use another one + // flexSelenium.flexSetFlexObjID("cloudWizard"); + waitForFlexExists("workspaceTree", 20, flexSelenium); + assertTrue(flexSelenium.getFlexEnabled("startButton").equals("true")); + + flexSelenium.flexSelectIndex("workspaceTree", String.valueOf(count)); +// flexSelenium.flexType("resourceName_txi", "bueno"); + flexSelenium.flexClick("startButton"); + Thread.sleep(5000); + assertTrue("Assertion failed. Lesson has *not* been created", lastCreatedLessonId < getLastCreatedLessonId(true)); + + //TODO fix CloudWizard or define offset checking for lesson's LD name + Long lessonId = getLastCreatedLessonId(false); + String lessonTitle = lessonDAO.getLesson(lessonId).getLearningDesign().getTitle(); + assertTrue("Tests aborted due to the problem with CloudWizard's root element problem. Please, restart tests", learningDesignName.equals(lessonTitle)); + } + + /** + * Prepares learning environment. Should be invoked each time learning is going to be tested. + * @throws InterruptedException + */ + protected void setUpLearning() throws InterruptedException { + selenium.runScript("openLearner(" + getLastCreatedLessonId(false) + ")"); + selenium.waitForPopUp("lWindow", "30000"); + selenium.selectWindow("lWindow"); + waitForElementPresent("contentFrame"); + selenium.selectFrame("contentFrame"); + } + + /** + * Shuts up learning environment. Should be invoked each time learning testing is done. + */ + protected void tearDownLearning() { + selenium.close(); + selenium.selectWindow(null); + } + + /** + * Launches Lams monitor, followed by tool's monitor popup. + */ + protected void openToolMonitor() { + Long lastCreatedLessonId = getLastCreatedLessonId(false); + LearningDesign learningDesign = lessonDAO.getLesson(lastCreatedLessonId).getLearningDesign(); + String contentFolderID = learningDesign.getContentFolderID(); + Activity activity = learningDesign.getFirstActivity(); + // doing this to prevent CGILib initialization exception + ToolActivity toolActivity = (ToolActivity) activityDAO.getActivityByActivityId(activity.getActivityId()); + + selenium.runScript("openMonitorLesson(" + lastCreatedLessonId + ")"); + selenium.waitForPopUp("mWindow", "15000"); + + // openning tool monitor popup + Tool tool = toolDAO.getToolBySignature(getToolSignature()); + String monitorUrl = TestFrameworkConstants.WEB_APP_DIR + tool.getMonitorUrl() + + "?toolContentID=" + toolActivity.getToolContentId() + + "&contentFolderID=" + contentFolderID; + final String monitorId = "monitorId"; + selenium.openWindow(monitorUrl, monitorId); + selenium.waitForPopUp(monitorId, "50000"); + selenium.selectWindow(monitorId); + } + + /** + * Closes Lams monitor. (Optional activity) + */ + protected void closeToolMonitor() { + selenium.close(); + selenium.selectWindow(null); + } + + + /** */ + protected void loginToLams() throws Exception { + selenium.open(TestFrameworkConstants.WEB_APP_DIR); + selenium.type("j_username", TestFrameworkConstants.USER_LOGIN); + selenium.type("j_password", TestFrameworkConstants.USER_PASSWORD); + selenium.click("//p[@class='login-button']/a"); + selenium.waitForPageToLoad("10000"); + Thread.sleep(3000); + } + + // ***************************************************************************** + // methods for testing Flex + // ***************************************************************************** + + /** + * Waits till element will be present on a page. + * + * @param locator - an element locator + * @throws InterruptedException + */ + protected void waitForElementPresent(String locator) throws InterruptedException { + for (int second = 0;; second++) { + if (second >= 30) { + fail("Timeout while waiting for element with locator " + locator); + } + try { + if (selenium.isElementPresent(locator)) { + break; + } + } catch (Exception e) { + } + Thread.sleep(1000); + } + } + + public String getText() { + return selenium.getEval("this.page().bodyText()"); + } + + protected void waitForFlexExists(String objectID, int timeout, DefaultSeleniumFlex selenium) throws Exception { + while (timeout > 0 && !selenium.getFlexExists(objectID).contains("true")) { + Thread.sleep(1000); + timeout--; + } + if (timeout == 0) { + throw new Exception("waitForFlexExists flex object:" + objectID + " Timed Out"); + } + } + + protected void waitForFlexVisible(String objectID, int timeout, + DefaultSeleniumFlex selenium) throws Exception { + while (timeout > 0 && !selenium.getFlexVisible(objectID).equals("true")) { + Thread.sleep(1000); + timeout--; + } + if (timeout == 0) { + throw new Exception("waitForFlexVisible flex object:" + objectID + + " Timed Out"); + } + } + + + + // ***************************************************************************** + // auxiliary methods + // ***************************************************************************** + + /** + * Returns lessonId of the last created lesson. + * + * @return id + */ + private Long getLastCreatedLessonId(boolean returnNegative) { + Integer userID = userManagementService.getUserByLogin(TestFrameworkConstants.USER_LOGIN).getUserId(); + List lessonsCreatedByUser = lessonDAO.getLessonsCreatedByUser(userID); + List lessonsWithLDName = new ArrayList(); + for (Lesson lesson : lessonsCreatedByUser) { + if (lesson.getLessonName().equals(learningDesignName)){ + lessonsWithLDName.add(lesson); + } + } + if (lessonsWithLDName.size() == 0) { + if (returnNegative) { + return new Long(-1); + } else { + fail("Lesson creation failed."); + } + } + + Lesson lastCreatedLesson = lessonsCreatedByUser.iterator().next(); + for (Lesson lesson : lessonsWithLDName) { + if (lesson.getCreateDateTime().after(lastCreatedLesson.getCreateDateTime()) ){ + lastCreatedLesson = lesson; + } + } + return lastCreatedLesson.getLessonId(); + } + + /** + * Given a WDDX packet in our normal format, gets the id number from within + * the <var + * name='messageValue'><number>num</number></var> + * + * @param wddxPacket + * @return id + */ + private String extractFolderIDFromWDDXPacket(String wddxPacket) { + int indexMessageValue = wddxPacket.indexOf(""); + assertTrue(" string not found", indexMessageValue > 0); + int endIndexMessageValue = wddxPacket.indexOf("", indexMessageValue); + return wddxPacket.substring(indexMessageValue + + "".length(), endIndexMessageValue); + } + + /** + * Given a WDDX packet in our normal format, gets the id number from within + * the <var + * name='messageValue'><number>num</number></var> + * + * @param wddxPacket + * @return id + */ + private String extractToolContentIDFromWDDXPacket(String wddxPacket) { + int indexMessageValue = wddxPacket.indexOf(""); + assertTrue(wddxPacket + "!! string not found", indexMessageValue > 0); + int endIndexMessageValue = wddxPacket.indexOf(".0", indexMessageValue); + String idString = wddxPacket.substring(indexMessageValue + + "".length(), + endIndexMessageValue); + try { + Long.parseLong(idString); + return idString; + } catch (NumberFormatException e) { + fail("Unable to get id number from WDDX packet. Format exception. String was " + + idString); + } + return null; + } + + /** + * Constructs wddx packet(the same as Flash creates) which contains LD details. + * + * @return + */ + private String constructWddxDesign(Map contentDetails) { + User user = userManagementService.getUserByLogin(TestFrameworkConstants.USER_LOGIN); + Tool tool = toolDAO.getToolBySignature(getToolSignature()); + + //checks if another LD with the same name exists. If so then trying to create unique one. + Workspace workspace = (Workspace) activityDAO.find(Workspace.class, user.getWorkspace().getWorkspaceId()); + Integer workspaceFolderID = workspace.getDefaultFolder().getWorkspaceFolderId(); + List existingTitles = learningDesignDAO.getLearningDesignTitlesByWorkspaceFolder(workspaceFolderID); + if (existingTitles.contains(learningDesignName)) { + int i = 2; + String tempLearningDesignName; + do { + tempLearningDesignName = learningDesignName + "(" + i++ + ")"; + } while (existingTitles.contains(tempLearningDesignName)); + learningDesignName = tempLearningDesignName; + } + + // searching for the template activity + ToolActivity templateActivity = null; + for (Object activityObject : activityDAO.getAllActivities()) { + if (activityObject instanceof ToolActivity) { + ToolActivity activity = (ToolActivity) activityObject; + if ((activity.getLearningDesign() == null) + && activity.getTool().getToolId().equals(tool.getToolId())) { + templateActivity = activity; + } + } + } + + String design = + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "string_null_value" + + "string_null_value" + + "" + tool.getToolId() + "" + + "" + contentDetails.get("toolContentID") + "" + + "" + tool.getToolSignature() + "" + + "" + tool.getToolDisplayName() + "" + + "" + tool.getHelpUrl() + "" + + "" + tool.getAuthorUrl() + "" + + "" + + "" + templateActivity.getGroupingSupportType() + "" + + "2009-6-12T1:24:50+3:0" + + "" + + "" + + "" + + "-111111" + + "-111111" + + "" + templateActivity.getLibraryActivityUiImage() + "" + + "124" + + "132" + + "" + templateActivity.getHelpText() + "" + + "" + templateActivity.getDescription() + "" + + "" + templateActivity.getTitle() + "" + + "" + templateActivity.getLearningLibrary().getLearningLibraryId() + "" + + //works with activityUIID=1 but may be we should generate unique one. + "1" + + "" + templateActivity.getActivityCategoryID() + "" + + "" + templateActivity.getActivityId() + "" + + "" + templateActivity.getActivityTypeId() + "" + + "" + + "" + + "" + + "" + contentDetails.get("contentFolderID") + "" + + "2009-6-24T22:45:24+3:0" + + "" + workspaceFolderID + "" + + "1" + + "0" + + "" + + "" + + "" + user.getUserId() + "" + + "" + learningDesignName + "" + + "-111111" + + "1" + + "" + + "" + + ""; + return design; + } + + // /** + // * Given a WDDX packet in our normal format, return the map object in the + // messageValue parameter. This should + // * contain any returned ids. + // * + // * @param wddxPacket + // * @return Map + // */ + // protected String extractIdMapFromWDDXPacket(String wddxPacket) { + // + // Object obj = null; + // try { + // obj = WDDXProcessor.deserialize(wddxPacket); + // } catch (WddxDeserializationException e1) { + // fail("WddxDeserializationException " + e1.getMessage()); + // e1.printStackTrace(); + // } + // // WDDXProcessor.convertToBoolean(table, key) + // + // Map map = (Map) obj; + // Object uniqueContentFolderObj = map.get("createUniqueContentFolder"); + // assertNotNull("createUniqueContentFolder object found", + // uniqueContentFolderObj); + // if (!String.class.isInstance(uniqueContentFolderObj)) { + // fail("createUniqueContentFolder is not a String - try extractIdFromWDDXPacket(packet)"); + // } + // + // return (String) uniqueContentFolderObj; + // } + +} Index: lams_common/test/java/org/lamsfoundation/lams/selenium/DefaultSeleniumFlex.java =================================================================== diff -u --- lams_common/test/java/org/lamsfoundation/lams/selenium/DefaultSeleniumFlex.java (revision 0) +++ lams_common/test/java/org/lamsfoundation/lams/selenium/DefaultSeleniumFlex.java (revision 56fb29e56260a46b9cc90c273018a01f93361631) @@ -0,0 +1,182 @@ + +/* + * License + * + * This file is part of The SeleniumFlex-API. + * + * The SeleniumFlex-API is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or any later version. + * + * The SeleniumFlex-API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The SeleniumFlex-API. + * If not, see http://www.gnu.org/licenses/ + * + */ + +package org.lamsfoundation.lams.selenium; + +import com.thoughtworks.selenium.DefaultSelenium; +import com.thoughtworks.selenium.HttpCommandProcessor; +import com.thoughtworks.selenium.SeleniumException; + + +public class DefaultSeleniumFlex extends DefaultSelenium { + + public DefaultSeleniumFlex(HttpCommandProcessor proc) { + super(proc); + } + + protected void handleException(SeleniumException e, String command, String target, String args) { + System.out.println(e.getMessage()); + System.out.println("Failed command : " + command + "(" + target + ", " + args +")"); + } + + protected String executeCommand(String command, String target, String args) throws Exception { + String retval = ""; + try { + retval = this.commandProcessor.doCommand(command, new String[] { target, args }); + } catch (SeleniumException e) { + handleException(e, command, target, args); + throw e; + } + return retval; + } + + public String getFlexSelectedItemAtIndex(String target, String args) throws Exception { return executeCommand("getFlexSelectedItemAtIndex", target, args).replace("OK,", ""); } + public String getFlexSelectedItemAtIndex(String target) throws Exception { return executeCommand("getFlexSelectedItemAtIndex", target, "").replace("OK,", ""); } + public String getFlexNumSelectedItems(String target, String args) throws Exception { return executeCommand("getFlexNumSelectedItems", target, args).replace("OK,", ""); } + public String getFlexNumSelectedItems(String target) throws Exception { return executeCommand("getFlexNumSelectedItems", target, "").replace("OK,", ""); } + public String getFlexVisible(String target, String args) throws Exception { return executeCommand("getFlexVisible", target, args).replace("OK,", ""); } + public String getFlexVisible(String target) throws Exception { return executeCommand("getFlexVisible", target, "").replace("OK,", ""); } + public String getFlexTextPresent(String target, String args) throws Exception { return executeCommand("getFlexTextPresent", target, args).replace("OK,", ""); } + public String getFlexTextPresent(String target) throws Exception { return executeCommand("getFlexTextPresent", target, "").replace("OK,", ""); } + public String getFlexText(String target, String args) throws Exception { return executeCommand("getFlexText", target, args).replace("OK,", ""); } + public String getFlexText(String target) throws Exception { return executeCommand("getFlexText", target, "").replace("OK,", ""); } + public String getFlexStepper(String target, String args) throws Exception { return executeCommand("getFlexStepper", target, args).replace("OK,", ""); } + public String getFlexStepper(String target) throws Exception { return executeCommand("getFlexStepper", target, "").replace("OK,", ""); } + public String getFlexSelectionIndex(String target, String args) throws Exception { return executeCommand("getFlexSelectionIndex", target, args).replace("OK,", ""); } + public String getFlexSelectionIndex(String target) throws Exception { return executeCommand("getFlexSelectionIndex", target, "").replace("OK,", ""); } + public String getFlexSelection(String target, String args) throws Exception { return executeCommand("getFlexSelection", target, args).replace("OK,", ""); } + public String getFlexSelection(String target) throws Exception { return executeCommand("getFlexSelection", target, "").replace("OK,", ""); } + public String getFlexRadioButton(String target, String args) throws Exception { return executeCommand("getFlexRadioButton", target, args).replace("OK,", ""); } + public String getFlexRadioButton(String target) throws Exception { return executeCommand("getFlexRadioButton", target, "").replace("OK,", ""); } + public String getFlexProperty(String target, String args) throws Exception { return executeCommand("getFlexProperty", target, args).replace("OK,", ""); } + public String getFlexProperty(String target) throws Exception { return executeCommand("getFlexProperty", target, "").replace("OK,", ""); } + public String getFlexParseInt(String target, String args) throws Exception { return executeCommand("getFlexParseInt", target, args).replace("OK,", ""); } + public String getFlexParseInt(String target) throws Exception { return executeCommand("getFlexParseInt", target, "").replace("OK,", ""); } + public String getFlexNumeric(String target, String args) throws Exception { return executeCommand("getFlexNumeric", target, args).replace("OK,", ""); } + public String getFlexNumeric(String target) throws Exception { return executeCommand("getFlexNumeric", target, "").replace("OK,", ""); } + public String getFlexGlobalPosition(String target, String args) throws Exception { return executeCommand("getFlexGlobalPosition", target, args).replace("OK,", ""); } + public String getFlexGlobalPosition(String target) throws Exception { return executeCommand("getFlexGlobalPosition", target, "").replace("OK,", ""); } + public String getFlexExists(String target, String args) throws Exception { return executeCommand("getFlexExists", target, args).replace("OK,", ""); } + public String getFlexExists(String target) throws Exception { return this.commandProcessor.doCommand("getFlexExists", new String[] { target, }); } + public String getFlexErrorString(String target, String args) throws Exception { return executeCommand("getFlexErrorString", target, args).replace("OK,", ""); } + public String getFlexErrorString(String target) throws Exception { return executeCommand("getFlexErrorString", target, "").replace("OK,", ""); } + public String getFlexEnabled(String target, String args) throws Exception { return executeCommand("getFlexEnabled", target, args).replace("OK,", ""); } + public String getFlexEnabled(String target) throws Exception { return executeCommand("getFlexEnabled", target, "").replace("OK,", ""); } + public String getFlexDate(String target, String args) throws Exception { return executeCommand("getFlexDate", target, args).replace("OK,", ""); } + public String getFlexDate(String target) throws Exception { return executeCommand("getFlexDate", target, "").replace("OK,", ""); } + public String getFlexDataGridUIComponentLabel(String target, String args) throws Exception { return executeCommand("getFlexDataGridUIComponentLabel", target, args).replace("OK,", ""); } + public String getFlexDataGridUIComponentLabel(String target) throws Exception { return executeCommand("getFlexDataGridUIComponentLabel", target, "").replace("OK,", ""); } + public String getFlexDataGridRowIndexForFieldValue(String target, String args) throws Exception { return executeCommand("getFlexDataGridRowIndexForFieldValue", target, args).replace("OK,", ""); } + public String getFlexDataGridRowIndexForFieldValue(String target) throws Exception { return executeCommand("getFlexDataGridRowIndexForFieldValue", target, "").replace("OK,", ""); } + public String getFlexDataGridRowCount(String target, String args) throws Exception { return executeCommand("getFlexDataGridRowCount", target, args).replace("OK,", ""); } + public String getFlexDataGridRowCount(String target) throws Exception { return executeCommand("getFlexDataGridRowCount", target, "").replace("OK,", ""); } + public String getFlexDataGridFieldValueForGridRow(String target, String args) throws Exception { return executeCommand("getFlexDataGridFieldValueForGridRow", target, args).replace("OK,", ""); } + public String getFlexDataGridFieldValueForGridRow(String target) throws Exception { return executeCommand("getFlexDataGridFieldValueForGridRow", target, "").replace("OK,", ""); } + public String getFlexDataGridCellText(String target, String args) throws Exception { return executeCommand("getFlexDataGridCellText", target, args).replace("OK,", ""); } + public String getFlexDataGridCellText(String target) throws Exception { return executeCommand("getFlexDataGridCellText", target, "").replace("OK,", ""); } + public String getFlexDataGridCell(String target, String args) throws Exception { return executeCommand("getFlexDataGridCell", target, args).replace("OK,", ""); } + public String getFlexDataGridCell(String target) throws Exception { return executeCommand("getFlexDataGridCell", target, "").replace("OK,", ""); } + public String getFlexComponentInfo(String target, String args) throws Exception { return executeCommand("getFlexComponentInfo", target, args).replace("OK,", ""); } + public String getFlexComponentInfo(String target) throws Exception { return executeCommand("getFlexComponentInfo", target, "").replace("OK,", ""); } + public String getFlexComboContainsLabel(String target, String args) throws Exception { return executeCommand("getFlexComboContainsLabel", target, args).replace("OK,", ""); } + public String getFlexComboContainsLabel(String target) throws Exception { return executeCommand("getFlexComboContainsLabel", target, "").replace("OK,", ""); } + public String getFlexCheckBoxChecked(String target, String args) throws Exception { return executeCommand("getFlexCheckBoxChecked", target, args).replace("OK,", ""); } + public String getFlexCheckBoxChecked(String target) throws Exception { return executeCommand("getFlexCheckBoxChecked", target, "").replace("OK,", ""); } + public String getFlexAlertTextPresent(String target, String args) throws Exception { return executeCommand("getFlexAlertTextPresent", target, args).replace("OK,", ""); } + public String getFlexAlertTextPresent(String target) throws Exception { return executeCommand("getFlexAlertTextPresent", target, "").replace("OK,", ""); } + public String getFlexAlertText(String target, String args) throws Exception { return executeCommand("getFlexAlertText", target, args).replace("OK,", ""); } + public String getFlexAlertText(String target) throws Exception { return executeCommand("getFlexAlertText", target, "").replace("OK,", ""); } + public String getFlexAlertPresent(String target, String args) throws Exception { return executeCommand("getFlexAlertPresent", target, args).replace("OK,", ""); } + public String getFlexAlertPresent(String target) throws Exception { return executeCommand("getFlexAlertPresent", target, "").replace("OK,", ""); } + public String getFlexASProperty(String target, String args) throws Exception { return executeCommand("getFlexASProperty", target, args).replace("OK,", ""); } + public String getFlexASProperty(String target) throws Exception { return executeCommand("getFlexASProperty", target, "").replace("OK,", ""); } + public String getDataGridUIComponentLabel(String target, String args) throws Exception { return executeCommand("getDataGridUIComponentLabel", target, args).replace("OK,", ""); } + public String getDataGridUIComponentLabel(String target) throws Exception { return executeCommand("getDataGridUIComponentLabel", target, "").replace("OK,", ""); } + public String getDataGridCellText(String target, String args) throws Exception { return executeCommand("getDataGridCellText", target, args).replace("OK,", ""); } + public String getDataGridCellText(String target) throws Exception { return executeCommand("getDataGridCellText", target, "").replace("OK,", ""); } + public void doRefreshIDToolTips(String target, String args) throws Exception { executeCommand("doRefreshIDToolTips", target, args); } + public void doRefreshIDToolTips(String target) throws Exception { executeCommand("doRefreshIDToolTips", target, ""); } + public void flexWaitForElementVisible(String target, String args) throws Exception { executeCommand("flexWaitForElementVisible", target, args); } + public void flexWaitForElementVisible(String target) throws Exception { executeCommand("flexWaitForElementVisible", target, ""); } + public void flexWaitForElement(String target, String args) throws Exception { executeCommand("flexWaitForElement", target, args); } + public void flexWaitForElement(String target) throws Exception { executeCommand("flexWaitForElement", target, ""); } + public void flexTypeAppend(String target, String args) throws Exception { executeCommand("flexTypeAppend", target, args); } + public void flexTypeAppend(String target) throws Exception { executeCommand("flexTypeAppend", target, ""); } + public void flexType(String target, String args) throws Exception { executeCommand("flexType", target, args); } + public void flexType(String target) throws Exception { executeCommand("flexType", target, ""); } + public void flexStepper(String target, String args) throws Exception { executeCommand("flexStepper", target, args); } + public void flexStepper(String target) throws Exception { executeCommand("flexStepper", target, ""); } + public void flexSetFocus(String target, String args) throws Exception { executeCommand("flexSetFocus", target, args); } + public void flexSetFocus(String target) throws Exception { executeCommand("flexSetFocus", target, ""); } + public void flexSetDataGridCell(String target, String args) throws Exception { executeCommand("flexSetDataGridCell", target, args); } + public void flexSetDataGridCell(String target) throws Exception { executeCommand("flexSetDataGridCell", target, ""); } + public void flexSelectMatchingOnField(String target, String args) throws Exception { executeCommand("flexSelectMatchingOnField", target, args); } + public void flexSelectMatchingOnField(String target) throws Exception { executeCommand("flexSelectMatchingOnField", target, ""); } + public void flexSelectIndex(String target, String args) throws Exception { executeCommand("flexSelectIndex", target, args); } + public void flexSelectIndex(String target) throws Exception { executeCommand("flexSelectIndex", target, ""); } + public void flexSelectComboByLabel(String target, String args) throws Exception { executeCommand("flexSelectComboByLabel", target, args); } + public void flexSelectComboByLabel(String target) throws Exception { executeCommand("flexSelectComboByLabel", target, ""); } + public void flexSelect(String target, String args) throws Exception { executeCommand("flexSelect", target, args); } + public void flexSelect(String target) throws Exception { executeCommand("flexSelect", target, ""); } + public void flexRefreshIDToolTips(String target, String args) throws Exception { executeCommand("flexRefreshIDToolTips", target, args); } + public void flexRefreshIDToolTips(String target) throws Exception { executeCommand("flexRefreshIDToolTips", target, ""); } + public void flexRadioButton(String target, String args) throws Exception { executeCommand("flexRadioButton", target, args); } + public void flexRadioButton(String target) throws Exception { executeCommand("flexRadioButton", target, ""); } + public void flexProperty(String target, String args) throws Exception { executeCommand("flexProperty", target, args); } + public void flexProperty(String target) throws Exception { executeCommand("flexProperty", target, ""); } + public void flexMouseUp(String target, String args) throws Exception { executeCommand("flexMouseUp", target, args); } + public void flexMouseUp(String target) throws Exception { executeCommand("flexMouseUp", target, ""); } + public void flexMouseRollOver(String target, String args) throws Exception { executeCommand("flexMouseRollOver", target, args); } + public void flexMouseRollOver(String target) throws Exception { executeCommand("flexMouseRollOver", target, ""); } + public void flexMouseRollOut(String target, String args) throws Exception { executeCommand("flexMouseRollOut", target, args); } + public void flexMouseRollOut(String target) throws Exception { executeCommand("flexMouseRollOut", target, ""); } + public void flexMouseOver(String target, String args) throws Exception { executeCommand("flexMouseOver", target, args); } + public void flexMouseOver(String target) throws Exception { executeCommand("flexMouseOver", target, ""); } + public void flexMouseMove(String target, String args) throws Exception { executeCommand("flexMouseMove", target, args); } + public void flexMouseMove(String target) throws Exception { executeCommand("flexMouseMove", target, ""); } + public void flexMouseDown(String target, String args) throws Exception { executeCommand("flexMouseDown", target, args); } + public void flexMouseDown(String target) throws Exception { executeCommand("flexMouseDown", target, ""); } + public void flexDragTo(String target, String args) throws Exception { executeCommand("flexDragTo", target, args); } + public void flexDragTo(String target) throws Exception { executeCommand("flexDragTo", target, ""); } + public void flexDoubleClick(String target, String args) throws Exception { executeCommand("flexDoubleClick", target, args); } + public void flexDoubleClick(String target) throws Exception { executeCommand("flexDoubleClick", target, ""); } + public void flexDate(String target, String args) throws Exception { executeCommand("flexDate", target, args); } + public void flexDate(String target) throws Exception { executeCommand("flexDate", target, ""); } + public void flexClickMenuBarUIComponent(String target, String args) throws Exception { executeCommand("flexClickMenuBarUIComponent", target, args); } + public void flexClickMenuBarUIComponent(String target) throws Exception { executeCommand("flexClickMenuBarUIComponent", target, ""); } + public void flexClickDataGridUIComponent(String target, String args) throws Exception { executeCommand("flexClickDataGridUIComponent", target, args); } + public void flexClickDataGridUIComponent(String target) throws Exception { executeCommand("flexClickDataGridUIComponent", target, ""); } + public void flexClickDataGridItem(String target, String args) throws Exception { executeCommand("flexClickDataGridItem", target, args); } + public void flexClickDataGridItem(String target) throws Exception { executeCommand("flexClickDataGridItem", target, ""); } + public void flexClick(String target, String args) throws Exception { executeCommand("flexClick", target, args); } + public void flexClick(String target) throws Exception { executeCommand("flexClick", target, ""); } + public void flexCheckBox(String target, String args) throws Exception { executeCommand("flexCheckBox", target, args); } + public void flexCheckBox(String target) throws Exception { executeCommand("flexCheckBox", target, ""); } + public void flexAlertResponse(String target, String args) throws Exception { executeCommand("flexAlertResponse", target, args); } + public void flexAlertResponse(String target) throws Exception { executeCommand("flexAlertResponse", target, ""); } + public void flexAddSelectMatchingOnField(String target, String args) throws Exception { executeCommand("flexAddSelectMatchingOnField", target, args); } + public void flexAddSelectMatchingOnField(String target) throws Exception { executeCommand("flexAddSelectMatchingOnField", target, ""); } + public void flexAddSelectIndex(String target, String args) throws Exception { executeCommand("flexAddSelectIndex", target, args); } + public void flexAddSelectIndex(String target) throws Exception { executeCommand("flexAddSelectIndex", target, ""); } +} + + \ No newline at end of file Index: lams_common/test/java/org/lamsfoundation/lams/selenium/TestFrameworkConstants.java =================================================================== diff -u --- lams_common/test/java/org/lamsfoundation/lams/selenium/TestFrameworkConstants.java (revision 0) +++ lams_common/test/java/org/lamsfoundation/lams/selenium/TestFrameworkConstants.java (revision 56fb29e56260a46b9cc90c273018a01f93361631) @@ -0,0 +1,46 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.selenium; + +public class TestFrameworkConstants { + + /** the host name on which the Selenium Server resides */ + public static final String SERVER_HOST = "localhost"; + /** the port on which the Selenium Server is listening */ + public static final int SERVER_PORT = 5555; + /** + * the command string used to launch the browser, e.g. "firefox" or + * "c:\\program files\\internet explorer\\iexplore.exe" + */ + public static final String BROWSER = "*firefox"; + public static final String WEB_APP_HOST = "http://127.0.0.1:8080"; + /** + * the starting URL including just a domain name. We'll start the browser + * pointing at the Selenium resources on this URL, + */ + public static final String WEB_APP_DIR = "/lams/"; + public static final String USER_LOGIN = "mmm"; + public static final String USER_PASSWORD = "mmm"; + +} Index: lams_common/test/java/org/lamsfoundation/lams/selenium/TestFrameworkException.java =================================================================== diff -u --- lams_common/test/java/org/lamsfoundation/lams/selenium/TestFrameworkException.java (revision 0) +++ lams_common/test/java/org/lamsfoundation/lams/selenium/TestFrameworkException.java (revision 56fb29e56260a46b9cc90c273018a01f93361631) @@ -0,0 +1,68 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.selenium; + +/** + * + * + * @author Andrey Balan + */ +public class TestFrameworkException extends RuntimeException { + + + private static final long serialVersionUID = -5273169461546526467L; + + /** + * Constructor for TestFrameworkException. + */ + public TestFrameworkException() { + super(); + } + + /** + * Constructor for TestFrameworkException. + * @param message + */ + public TestFrameworkException(String message) { + super(message); + } + + /** + * Constructor for TestFrameworkException. + * @param message + * @param cause + */ + public TestFrameworkException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor for TestFrameworkException. + * @param cause + */ + public TestFrameworkException(Throwable cause) { + super(cause); + } + +}