Search in sources :

Example 31 with Poster

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

the class VerifyProfile method verifyProfile.

public static Poster verifyProfile(WebDriver driver, String userId) {
    Poster poster = new Poster(userId);
    WebElement postCount = driver.findElement(className(POST_COUNT)).findElement(xpath("tbody/tr[3]/td[2]"));
    int count = new Integer(postCount.getText().trim());
    for (int i = 0; i < count; i++) poster.incrementPostCount();
    return poster;
}
Also used : Poster(it.vige.rubia.model.Poster) WebElement(org.openqa.selenium.WebElement)

Example 32 with Poster

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

the class VerifyPost method getPostsOfCurrentTopic.

public static List<Post> getPostsOfCurrentTopic(WebDriver driver) {
    List<WebElement> postComponents = driver.findElements(className(BODY_OUTPUT_TEXT));
    int postComponentsSize = postComponents.size();
    List<Post> posts = new ArrayList<Post>();
    for (int i = 0; i < postComponentsSize; i++) {
        Post post = new Post();
        WebElement postComponent = driver.findElements(className(BODY_OUTPUT_TEXT)).get(i);
        String body = postComponent.findElement(xpath("p")).getText();
        String post_subject = postComponent.findElement(xpath(POST_SUBJECT_OUTPUT_TEXT)).getText().split(POST_SUBJECT_TEXT)[1];
        String createDateStr = postComponent.findElement(xpath(CREATE_DATE_OUTPUT_TEXT)).getText().split(CREATE_DATE_TEXT)[1];
        Date createDate = null;
        try {
            createDate = dateFormat.parse(createDateStr);
        } catch (ParseException e) {
            log.error(e);
        }
        Message message = new Message();
        message.setSubject(post_subject);
        message.setText(body);
        post.setMessage(message);
        post.setCreateDate(createDate);
        WebElement topicEl = driver.findElement(TOPIC_TEMPLATE_LINK.getValue());
        Topic topic = new Topic(topicEl.getText());
        post.setTopic(topic);
        WebElement forumEl = driver.findElement(FORUM_TEMPLATE_LINK.getValue());
        topic.setForum(new Forum(forumEl.getText()));
        post.setAttachments(getAttachmentsOfCurrentPostInPage(driver, post));
        addParents(driver, post);
        Poster poster = new Poster();
        postComponent = driver.findElements(className(BODY_OUTPUT_TEXT)).get(i);
        poster.setUserId(postComponent.findElement(xpath(USER_LINK)).getText());
        post.setPoster(poster);
        posts.add(post);
    }
    return posts;
}
Also used : Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement) Date(java.util.Date) Forum(it.vige.rubia.model.Forum) Poster(it.vige.rubia.model.Poster) ParseException(java.text.ParseException) Topic(it.vige.rubia.model.Topic)

Example 33 with Poster

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

the class VerifyPost method getPosterFromLink.

public static Poster getPosterFromLink(WebDriver driver, Post post) {
    WebElement profileLink = driver.findElements(className(FORUM_TABLE)).get(1).findElement(xpath("tbody/tr/td/p[contains(text(),'" + post.getMessage().getText() + "')]")).findElement(xpath("../../../tr/td/a"));
    String userId = profileLink.getText();
    profileLink.click();
    Poster poster = verifyProfile(driver, userId);
    return poster;
}
Also used : Poster(it.vige.rubia.model.Poster) WebElement(org.openqa.selenium.WebElement)

Example 34 with Poster

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

the class VerifyPost method getPosterFromButton.

public static Poster getPosterFromButton(WebDriver driver, Post post) {
    WebElement profileLink = driver.findElements(className(FORUM_TABLE)).get(1).findElement(xpath("tbody/tr/td/p[contains(text(),'" + post.getMessage().getText() + "')]")).findElement(xpath("../../../tr/td"));
    String userId = profileLink.getText();
    WebElement button = driver.findElements(className(FORUM_TABLE)).get(1).findElement(xpath("tbody/tr/td/p[contains(text(),'" + post.getMessage().getText() + "')]")).findElement(xpath("../../../tr[3]/td[2]/ul/li/a"));
    button.click();
    Poster poster = verifyProfile(driver, userId);
    return poster;
}
Also used : Poster(it.vige.rubia.model.Poster) WebElement(org.openqa.selenium.WebElement)

Example 35 with Poster

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

the class ReplyTopic method startQuote.

/**
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String startQuote() {
    String navState = start();
    try {
        String p = getParameter(p_postId);
        if (p != null && p.trim().length() > 0) {
            postId = parseInt(p);
        }
        // setup the quote information
        Post post = forumsModule.findPostById(postId);
        Poster poster = getPoster(forumsModule, userModule);
        String userName = userModule.findUserById(poster.getUserId()).getUserName();
        message = userName + "<" + QUOTE + ">" + post.getMessage().getText() + "</" + QUOTE + "></br>";
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : Post(it.vige.rubia.model.Post) PortalUtil.getPoster(it.vige.rubia.PortalUtil.getPoster) Poster(it.vige.rubia.model.Poster) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Aggregations

Poster (it.vige.rubia.model.Poster)46 Post (it.vige.rubia.model.Post)20 WebElement (org.openqa.selenium.WebElement)18 Topic (it.vige.rubia.model.Topic)17 Forum (it.vige.rubia.model.Forum)14 Test (org.junit.Test)13 Message (it.vige.rubia.model.Message)11 ParseException (java.text.ParseException)10 Category (it.vige.rubia.model.Category)7 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)7 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)7 Date (java.util.Date)7 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)6 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)6 NoResultException (javax.persistence.NoResultException)6 NonUniqueResultException (javax.persistence.NonUniqueResultException)6 VerifyPost.getLastPostOfCurrentForum (it.vige.rubia.selenium.forum.action.VerifyPost.getLastPostOfCurrentForum)5 VerifyTopic (it.vige.rubia.selenium.forum.action.VerifyTopic)5 VerifyTopic.getPoster (it.vige.rubia.selenium.forum.action.VerifyTopic.getPoster)5 DateFormat (java.text.DateFormat)5