• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Selenium类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.thoughtworks.selenium.Selenium的典型用法代码示例。如果您正苦于以下问题:Java Selenium类的具体用法?Java Selenium怎么用?Java Selenium使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Selenium类属于com.thoughtworks.selenium包,在下文中一共展示了Selenium类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()"));
}
 
开发者ID:huihoo,项目名称:olat,代码行数:24,代码来源:LoginLoadTest.java


示例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("=====================================");
}
 
开发者ID:huihoo,项目名称:olat,代码行数:25,代码来源:WorkflowHelper.java


示例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");
}
 
开发者ID:huihoo,项目名称:olat,代码行数:33,代码来源:WorkflowHelper.java


示例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;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:23,代码来源:OlatLoginHelper.java


示例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;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:18,代码来源:MultiUserSearchTest.java


示例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");
}
 
开发者ID:huihoo,项目名称:olat,代码行数:21,代码来源:AssessmentWithCodepointsTest.java


示例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");
}
 
开发者ID:huihoo,项目名称:olat,代码行数:17,代码来源:WorkflowHelper.java


示例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;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:13,代码来源:Context.java


示例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");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:12,代码来源:LRDetailedView.java


示例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");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:11,代码来源:AssessmentElement.java


示例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;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:20,代码来源:SeleniumHelper.java


示例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");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:8,代码来源:QuestionnaireElementEditor.java


示例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");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:11,代码来源:SinglePageEditor.java


示例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");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:12,代码来源:SelfTestElementEditor.java


示例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");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:10,代码来源:FolderEditor.java


示例16: TestEditor

import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
 * @param selenium
 */
public TestEditor(Selenium selenium) {
    super(selenium);

    // Check that we're on the right place
    if (!selenium.isElementPresent("ui=testEditor::toolbox_add_addSection()")) {
        // it must have an Add Section link.
        throw new IllegalStateException("This is not the - Test editor - page");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:13,代码来源:TestEditor.java


示例17: DisposedCourseRun

import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
public DisposedCourseRun(Selenium selenium) {
    super(selenium);

    if (!selenium.isElementPresent("ui=course::disposed_closeAndRestart()")) {
        // click anywhere, the course run was disposed anyway
        selenium.click("ui=course::toolbox_generalTools_detailedView()");
        selenium.waitForPageToLoad("30000");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:10,代码来源:DisposedCourseRun.java


示例18: AssessmentForm

import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
 * @param selenium
 */
public AssessmentForm(Selenium selenium) {
    super(selenium);

    // Check that we're on the right place
    if (!selenium.isElementPresent("ui=commons::flexiForm_labeledTextInput(formElementLabel=Score)")
            && !selenium.isElementPresent("ui=course::assessment_setPassedYes()")) {
        // no set score and no set passed present
        throw new IllegalStateException("This is not the - Assessment form - page");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:14,代码来源:AssessmentForm.java


示例19: SCORM

import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
 * @param selenium
 */
public SCORM(Selenium selenium) {
    super(selenium);

    // Check that we're on the right place
    if (!selenium.isElementPresent("ui=course::content_scorm_scormPreview()")) {
        throw new IllegalStateException("This is not the - SCORM run - page");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:12,代码来源:SCORM.java


示例20: Group

import com.thoughtworks.selenium.Selenium; //导入依赖的package包/类
/**
 * @param selenium
 */
public Group(Selenium selenium, String groupName) {
    super(selenium);
    this.groupName = groupName;
    try {
        // delay at load group since 30.08.09
        Thread.sleep(10000);
    } catch (Exception e) {
    }
    // Check that we're on the right place
    if (!selenium.isTextPresent(groupName)) {
        throw new IllegalStateException("This is not the - Group - page");
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:17,代码来源:Group.java



注:本文中的com.thoughtworks.selenium.Selenium类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CacheResult类代码示例发布时间:2022-05-21
下一篇:
Java CachedData类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap