本文整理汇总了Java中com.thoughtworks.selenium.Selenium类的典型用法代码示例。如果您正苦于以下问题:Java Selenium类的具体用法?Java Selenium怎么用?Java Selenium使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Selenium类属于com.thoughtworks.selenium包,在下文中一共展示了Selenium类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleLoginSameBrowserWindow
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
*
* @param selenium
* @param loginInfos
* @throws Exception
*/
private void simpleLoginSameBrowserWindow(Selenium selenium, OlatLoginInfos loginInfos) throws Exception {
String username = loginInfos.getUsername();
String password = loginInfos.getPassword();
OlatLoginHelper.inputUserNameAndPassword(selenium, username, password);
int second = 0;
while (second < 20) {
try {
if (selenium.isElementPresent("ui=home::menu_settings()")) // logged in
break;
} catch (Exception e) {
}
Thread.sleep(500);
second++;
}
assertTrue(selenium.isElementPresent("ui=home::menu_settings()"));
}
示例2: deleteAllGroupsFromAuthor
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
public static void deleteAllGroupsFromAuthor(OlatLoginInfos loginInfos) {
System.out.println("=====================================");
System.out.println("DELETE ALL GROUPS FROM: " + loginInfos.getUsername());
System.out.println(" START");
System.out.println("=====================================");
Selenium selenium = Context.getContext().createSeleniumAndLogin(loginInfos);
selenium.click("ui=tabs::groups()");
selenium.waitForPageToLoad("30000");
selenium.click("ui=groups::menu_myProjectGroups()");
selenium.waitForPageToLoad("30000");
while (selenium.isElementPresent("ui=groups::content_deleteFirstGroup()")) {
selenium.click("ui=groups::content_deleteFirstGroup()");
selenium.waitForPageToLoad("30000");
selenium.click("ui=groups::content_deleteYes()");
selenium.waitForPageToLoad("30000");
System.out.println("Yes, we deleted a group!");
}
System.out.println("=====================================");
System.out.println("DELETE ALL GROUPS FROM: " + loginInfos.getUsername());
System.out.println(" END");
System.out.println("=====================================");
}
示例3: addOwnerToLearningResource
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* Administrator adds user with username as owner of the course with courseName.
*
* @param username
* @param courseName
* @throws Exception
*/
public static void addOwnerToLearningResource(String username, String courseName) throws Exception {
Selenium selenium = Context.getContext().createSeleniumAndLogin(Context.getContext().getStandardAdminOlatLoginInfos(1));
selenium.click("ui=tabs::learningResources()");
selenium.waitForPageToLoad("30000");
selenium.click("ui=learningResources::menu_searchForm()");
selenium.waitForPageToLoad("30000");
selenium.type("ui=commons::flexiForm_labeledTextInput(formElementLabel=Title of learning resource)", courseName);
selenium.click("ui=commons::flexiForm_genericLink(buttonLabel=Search)");
selenium.waitForPageToLoad("30000");
selenium.click("ui=learningResources::content_showDetailedView(nameOfLearningResource=" + courseName + ")");
selenium.waitForPageToLoad("30000");
selenium.click("ui=learningResources::toolbox_learningResource_assignOwners()");
selenium.waitForPageToLoad("30000");
selenium.click("ui=learningResources::toolbox_learningResource_assignOwners_addOwner()");
selenium.waitForPageToLoad("30000");
selenium.type("ui=commons::flexiForm_labeledTextInput(formElementLabel=User name)", username);
selenium.click("ui=commons::flexiForm_genericLink(buttonLabel=Search)");
selenium.waitForPageToLoad("30000");
selenium.click("ui=commons::usertable_adduser_checkUsername(nameOfUser=" + username + ")");
selenium.click("ui=commons::usertable_adduser_choose()");
selenium.click("ui=overlay::overlayClose()");
selenium.click("ui=tabs::logOut()");
selenium.waitForPageToLoad("30000");
}
示例4: loginExpectingError
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* Try to login but gets an error message.
*
* @param nodeId
* @param username
* @param password
* @return Returns true, if it gets an error msg at login.
*/
public static boolean loginExpectingError(int nodeId, String username, String password) throws Exception {
Selenium selenium = Context.getContext().createSelenium(Context.getContext().getOlatLoginInfo(nodeId, username, password));
assertEquals("OLAT - Online Learning And Training", selenium.getTitle());
System.out.println("logging in to " + selenium.getLocation() + " as " + username);
inputUserNameAndPassword(selenium, username, password);
boolean cannotLogin = SeleniumHelper.isTextPresent(selenium, "OLAT user name or password invalid", 20); // English error message
cannotLogin |= SeleniumHelper.isTextPresent(selenium, "Fehler", 20); // German error message
/*
* if(!cannotLogin) { fail("Expected to get an error message while login!"); }
*/
selenium.click("ui=dmz::loginErrorOK()");
return cannotLogin;
}
示例5: evaluateSearchResult
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* We consider that an successful search should find at least a result entry. If no result found or service not available - this is regarded as an invalid search
* result.
*
* @param selenium_
*/
private boolean evaluateSearchResult(Selenium selenium_, String luceneQuery) {
boolean noResults = selenium_.isTextPresent(NO_RESULTS_FOUND);
boolean resultsFound = selenium_.isTextPresent(RESULTS_FOUND);
boolean serviceNotAvailable = selenium_.isTextPresent(SERVICE_NOT_AVAILABLE_MSG);
boolean searchResultsFound = !serviceNotAvailable && (resultsFound && !noResults);
System.out.println("searchResultsFound: " + searchResultsFound + " for query: " + luceneQuery);
System.out.println("serviceNotAvailable: " + serviceNotAvailable);
System.out.println("resultsFound: " + resultsFound);
System.out.println("noResults: " + noResults);
return searchResultsFound;
}
示例6: enrollInGroupAfterLogin
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* STUDENT enrolls - login and enroll if not already member in groupName
*
* @param selenium_
* @param courseName
* @param groupName
*/
private void enrollInGroupAfterLogin(Selenium selenium_, String courseName, String groupName) {
WorkflowHelper.openCourseAfterLogin(selenium_, courseName);
selenium_.click("ui=course::menu_courseNode(titleOfNode=Enrolment)");
selenium_.waitForPageToLoad("30000");
boolean alreadyEnrolled = seleniumEquals("enrolled", selenium_.getText("ui=course::content_enrollment_enrolledOrNot(nameOfGroup=" + groupName + ")"));
if (!alreadyEnrolled) {
selenium_.click("ui=course::content_enrollment_enrolOnGroup(nameOfGroup=" + groupName + ")");
selenium_.waitForPageToLoad("30000");
assertTrue(selenium_.isTextPresent("You have already enroled for the learning group mentioned below"));
}
selenium_.click("ui=tabs::logOut()");
selenium_.waitForPageToLoad("30000");
}
示例7: openCourseAfterLogin
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* Enter "assessmentTool" course.
*
* @param selenium_
*/
public static void openCourseAfterLogin(Selenium selenium_, String courseName) {
selenium_.click("ui=tabs::learningResources()");
selenium_.waitForPageToLoad("30000");
selenium_.click("ui=learningResources::menu_searchForm()");
selenium_.waitForPageToLoad("30000");
selenium_.type("ui=commons::flexiForm_labeledTextInput(formElementLabel=Title of learning resource)", courseName);
selenium_.click("ui=commons::flexiForm_genericLink(buttonLabel=Search)");
selenium_.waitForPageToLoad("30000");
selenium_.click("ui=learningResources::content_clickLearningResource(nameOfLearningResource=" + courseName + ")");
selenium_.waitForPageToLoad("30000");
}
示例8: createSeleniumAndLogin
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
public Selenium createSeleniumAndLogin(OlatLoginInfos loginInfos) {
Selenium selenium = seleniumManager_.createSelenium(loginInfos);
OlatLoginHelper.olatLogin(selenium, loginInfos);
// make sure the login worked
if (!"OLAT - Home".equals(selenium.getTitle())) {
throw new AssertionError("createSeleniumAndLogin failed - expected to be logged in now and seeing 'OLAT - Home' - but instead I'm on this page: "
+ selenium.getTitle());
}
return selenium;
}
示例9: LRDetailedView
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* @param selenium
*/
public LRDetailedView(Selenium selenium) {
super(selenium);
// Check that we're on the right place
if (!selenium.isElementPresent("ui=learningResources::content_showContent()")) {
throw new IllegalStateException("This is not the - Detailed view - page");
}
}
示例10: AssessmentElement
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* @param selenium
*/
public AssessmentElement(Selenium selenium) {
super(selenium);
// Check that we're on the right place
if (!selenium.isElementPresent("ui=course::content_assessment_summaryOfScore()")) {
throw new IllegalStateException("This is not the - Assessment course element run - page");
}
}
示例11: isTextPresent
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* Checks if text shows up in the first timeoutSec.
*
* @param selenium
* @param text
* @param timeoutSec
* @return Return true if the test was present, else false.
*/
public static boolean isTextPresent(Selenium selenium, String text, int timeoutSec) throws Exception {
for (int second = 0; second <= timeoutSec; second++) {
try {
if (selenium.isTextPresent(text))
return true;
} catch (Exception e) {
}
Thread.sleep(1000);
}
return false;
}
示例12: QuestionnaireElementEditor
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
public QuestionnaireElementEditor(Selenium selenium) {
super(selenium);
// Check that we're on the right place
if (!selenium.isElementPresent("ui=courseEditor::content_bbQuestionnaire_tabQuestionnaireConfiguration()")) {
throw new IllegalStateException("This is not the - Questionnaire configuration - page");
}
}
示例13: SinglePageEditor
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* @param selenium
*/
public SinglePageEditor(Selenium selenium) {
super(selenium);
// Check that we're on the right place
if (!selenium.isElementPresent("ui=courseEditor::content_bbSinglePage_tabPageContent()")) {
throw new IllegalStateException("This is not the - Single page - page");
}
}
示例14: SelfTestElementEditor
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* @param selenium
*/
public SelfTestElementEditor(Selenium selenium) {
super(selenium);
// Check that we're on the right place
if (!selenium.isElementPresent("ui=courseEditor::content_bbSelfTest_tabSelfTestConfiguration()")) {
throw new IllegalStateException("This is not the - Self-test configuration - page");
}
}
示例15: FolderEditor
import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
* @param selenium
*/
public FolderEditor(Selenium selenium) {
super(selenium);
if (!selenium.isElementPresent("ui=courseEditor::content_bbFolder_tabFolderConfiguration()")) {
throw new IllegalStateException("This is not the - Folder editor - page");
}
}