Search in sources :

Example 41 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class ViewRSSLink method getPage.

public static Forum getPage(WebDriver driver, Forum forum) {
    VerifyForum.goTo(driver, forum);
    goTo(driver);
    Forum result = new Forum();
    result.setName(driver.findElement(id(FEED_TITLE_TEXT)).getText().split(": ")[1]);
    result.setCategory(new Category(driver.findElement(id(FEED_SUBTITLE_TEXT)).getText().split(" in category ")[1]));
    Map<String, Topic> topics = new HashMap<String, Topic>();
    List<WebElement> entries = driver.findElements(className(ENTRY_LINK));
    DateFormat dateFormat = new SimpleDateFormat("d MMM yyyy, HH:mm");
    for (WebElement entry : entries) {
        String[] entryText = entry.getText().split(BY);
        String lastUpdated = entry.findElement(className(LAST_UPDATED)).getText();
        String topicTitle = entryText[0].replace(RE, "");
        Topic topic = topics.get(topicTitle);
        if (topic == null) {
            topic = new Topic(topicTitle);
            topics.put(topicTitle, topic);
        }
        Post post = new Post(entry.findElement(className(FEED_ENTRY_CONTENT)).getText());
        post.setPoster(new Poster(entryText[1].split("\n")[0]));
        try {
            post.setCreateDate(dateFormat.parse(lastUpdated));
        } catch (ParseException e) {
        }
        post.getMessage().setSubject(entryText[0]);
        topic.getPosts().add(post);
    }
    result.setTopics(new ArrayList<Topic>(topics.values()));
    returnToHome(driver);
    return result;
}
Also used : Category(it.vige.rubia.model.Category) HashMap(java.util.HashMap) Post(it.vige.rubia.model.Post) WebElement(org.openqa.selenium.WebElement) Forum(it.vige.rubia.model.Forum) VerifyForum(it.vige.rubia.selenium.forum.action.VerifyForum) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Poster(it.vige.rubia.model.Poster) ParseException(java.text.ParseException) VerifyTopic(it.vige.rubia.selenium.forum.action.VerifyTopic) Topic(it.vige.rubia.model.Topic) SimpleDateFormat(java.text.SimpleDateFormat)

Example 42 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class LockForum method unlockForum.

public static String unlockForum(WebDriver driver, Forum forum) {
    if (forum != null)
        for (Topic topic : forum.getTopics()) {
            WebElement topicToSelect = driver.findElement(linkText(topic.getSubject())).findElement(xpath("../../td[5]/input"));
            topicToSelect.click();
        }
    WebElement unlockForum = driver.findElement(tagName(LOCK_FORUM)).findElement(xpath("tr/td/input[4]"));
    unlockForum.click();
    WebElement resultLockForum = driver.findElement(id(RESULT_LOCK_FORUM));
    String message = resultLockForum.getText();
    return message;
}
Also used : Topic(it.vige.rubia.model.Topic) WebElement(org.openqa.selenium.WebElement)

Example 43 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class LockForum method lockForum.

public static String lockForum(WebDriver driver, Forum forum) {
    if (forum != null)
        for (Topic topic : forum.getTopics()) {
            WebElement topicToSelect = driver.findElement(linkText(topic.getSubject())).findElement(xpath("../../td[5]/input"));
            topicToSelect.click();
        }
    WebElement lockForum = driver.findElement(tagName(LOCK_FORUM)).findElement(xpath("tr/td/input[3]"));
    lockForum.click();
    WebElement resultLockForum = driver.findElement(id(RESULT_LOCK_FORUM));
    String message = resultLockForum.getText();
    return message;
}
Also used : Topic(it.vige.rubia.model.Topic) WebElement(org.openqa.selenium.WebElement)

Example 44 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class MoveForum method moveForum.

public static String moveForum(WebDriver driver, OperationType moveType, Forum sourceForum, Forum destForum) {
    if (sourceForum != null)
        for (Topic topic : sourceForum.getTopics()) {
            WebElement topicToSelect = driver.findElement(linkText(topic.getSubject())).findElement(xpath("../../td[5]/input"));
            topicToSelect.click();
        }
    WebElement moveForum = driver.findElement(tagName(MOVE_FORUM)).findElement(xpath("tr/td/input[2]"));
    moveForum.click();
    String message = "";
    WebElement resultMoveForum = null;
    try {
        resultMoveForum = driver.findElement(id(RESULT_MOVE_FORUM));
        message = resultMoveForum.getText();
    } catch (NoSuchElementException ex) {
        if (moveType == CONFIRM) {
            if (destForum != null) {
                Select select = new Select(driver.findElement(name(SELECT_INPUT)));
                select.selectByVisibleText(destForum.getName());
            }
            WebElement option = driver.findElement(className(SELECT_TYPE)).findElement(xpath("input[1]"));
            option.click();
            resultMoveForum = driver.findElement(id(RESULT_MOVE_FORUM));
            message = resultMoveForum.getText();
        } else {
            WebElement option = driver.findElement(className(SELECT_TYPE)).findElement(xpath("input[2]"));
            option.click();
        }
        return message;
    }
    return message;
}
Also used : Select(org.openqa.selenium.support.ui.Select) Topic(it.vige.rubia.model.Topic) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 45 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class RemoveForum method removeForum.

public static String removeForum(WebDriver driver, OperationType removeType, Forum forum) {
    if (forum != null)
        for (Topic topic : forum.getTopics()) {
            WebElement topicToSelect = driver.findElement(linkText(topic.getSubject())).findElement(xpath("../../td[5]/input"));
            topicToSelect.click();
        }
    WebElement removeForum = driver.findElement(tagName(REMOVE_LINK)).findElement(xpath("tr/td/input[1]"));
    removeForum.click();
    String message = "";
    WebElement resultRemoveForum = null;
    try {
        resultRemoveForum = driver.findElement(id(RESULT_REMOVE_FORUM));
        message = resultRemoveForum.getText();
    } catch (NoSuchElementException ex) {
        if (removeType == CONFIRM) {
            WebElement option = driver.findElements(tagName(SELECT_TYPE)).get(1).findElement(xpath("input[3]"));
            option.click();
            resultRemoveForum = driver.findElement(id(RESULT_REMOVE_FORUM));
            message = resultRemoveForum.getText();
        } else {
            WebElement option = driver.findElements(tagName(SELECT_TYPE)).get(1).findElement(xpath("input[4]"));
            option.click();
        }
        return message;
    }
    return message;
}
Also used : Topic(it.vige.rubia.model.Topic) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Aggregations

Topic (it.vige.rubia.model.Topic)112 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)64 Forum (it.vige.rubia.model.Forum)63 Post (it.vige.rubia.model.Post)62 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)49 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)48 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)39 Category (it.vige.rubia.model.Category)36 Test (org.junit.Test)36 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)30 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)30 Poll (it.vige.rubia.model.Poll)25 PollOption (it.vige.rubia.model.PollOption)24 Attachment (it.vige.rubia.model.Attachment)23 Poster (it.vige.rubia.model.Poster)17 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)16 WebElement (org.openqa.selenium.WebElement)16 SecureActionForum (it.vige.rubia.auth.SecureActionForum)14 Date (java.util.Date)14 Interceptors (javax.interceptor.Interceptors)13