Search in sources :

Example 11 with Poll

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

the class VerifyPoll method getPollOfCurrentTopic.

public static Poll getPollOfCurrentTopic(WebDriver driver) {
    WebElement question = null;
    Poll poll = null;
    try {
        question = driver.findElement(className(QUESTION_OUTPUT_TEXT));
    } catch (NoSuchElementException ex) {
    }
    if (question != null) {
        poll = new Poll();
        poll.setTitle(question.getText());
        List<WebElement> pollComponents = driver.findElements(className(ANSWER_OUTPUT_TEXT));
        List<PollOption> pollOptions = new LinkedList<PollOption>();
        for (WebElement pollComponent : pollComponents) {
            PollOption pollOption = new PollOption();
            pollOption.setQuestion(pollComponent.getText());
            pollOption.setPoll(poll);
            pollOptions.add(pollOption);
        }
        WebElement votesResultComponent = driver.findElement(linkText(RESULT_VOTES_LINK));
        votesResultComponent.click();
        List<WebElement> pollComponentsTr = driver.findElement(className(FORUM_POLL_TABLE)).findElements(xpath("tbody/tr"));
        pollComponents.clear();
        for (int i2 = 0; i2 < pollComponentsTr.size(); i2++) {
            if (i2 != 0 && i2 < pollComponentsTr.size() - 2)
                pollComponents.add(pollComponentsTr.get(i2).findElement(xpath("td")));
        }
        for (int i3 = 0; i3 < pollOptions.size(); i3++) {
            WebElement pollComponent = pollComponents.get(i3);
            PollOption pollOption = pollOptions.get(i3);
            String numberOfVotes = driver.findElement(className(FORUM_POLL_TABLE)).findElement(xpath("tbody/tr[td/text()='" + pollComponent.getText() + "']/td[3]")).getText();
            String pollOptionPosition = driver.findElement(className(FORUM_POLL_TABLE)).findElement(xpath("tbody/tr[td/text()='" + pollComponent.getText() + "']/td[4]")).getText();
            pollOption.setVotes(new Integer(numberOfVotes.substring(0, numberOfVotes.length() - 1)));
            pollOption.setPollOptionPosition(new Integer(pollOptionPosition.substring(1, pollOptionPosition.length() - 1).trim()));
        }
        WebElement votesComponent = driver.findElement(linkText(VOTES_LINK));
        votesComponent.click();
        poll.setOptions(pollOptions);
    }
    return poll;
}
Also used : Poll(it.vige.rubia.model.Poll) PollOption(it.vige.rubia.model.PollOption) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) LinkedList(java.util.LinkedList)

Example 12 with Poll

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

the class OperationAttachmentTest method setUp.

@BeforeClass
public static void setUp() {
    driver.get(HOME_URL);
    String message = createCategory(driver, new Category("First Test Category"));
    assertTrue(message.equals(CREATED_CATEGORY_1_MESSAGE));
    message = createCategory(driver, new Category("Second Test Category"));
    assertTrue(message.equals(CREATED_CATEGORY_2_MESSAGE));
    message = createForum(driver, new Forum("First Test Forum", "First Test Description", new Category("First Test Category")));
    assertTrue(message.equals(CREATED_FORUM_0_MESSAGE));
    message = createTopic(driver, new Topic(new Forum("First Test Forum"), "First Test Topic", asList(new Post[] { new Post("First Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), NORMAL, new Poll("First Test Question", asList(new PollOption[] { new PollOption("First Test Answer"), new PollOption("Second Test Answer") }), 4)));
    assertTrue(message.equals("First Test Topic"));
    message = createPost(driver, new Post(new Topic(new Forum("First Test Forum"), "First Test Topic"), "First Test Post", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))));
    assertTrue(message.equals("First Test Post"));
    message = createPost(driver, new Post(new Topic(new Forum("First Test Forum"), "First Test Topic"), "Second Test Post", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))));
    assertTrue(message.equals("Second Test Post"));
    message = createTopic(driver, new Topic(new Forum("First Test Forum"), "Second Test Topic", asList(new Post[] { new Post("Second Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), IMPORTANT, new Poll("Second Test Question", asList(new PollOption[] { new PollOption("Third Test Answer"), new PollOption("Fourth Test Answer") }), 8)));
    assertTrue(message.equals("Second Test Topic"));
    message = createForum(driver, new Forum("Second Test Forum", "Second Test Description", new Category("First Test Category")));
    assertTrue(message.equals(CREATED_FORUM_1_MESSAGE));
    message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Third Test Topic", asList(new Post[] { new Post("Third Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), ADVICE, new Poll("Third Test Question", asList(new PollOption[] { new PollOption("Fifth Test with Truncation over 25 characters Answer"), new PollOption("Sixth Test Answer") }), 9)));
    assertTrue(message.equals("Third Test Topic"));
    message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Fourth Test Topic", asList(new Post[] { new Post("Fourth Test Body", asList(new Attachment("fourth", "Fourth Test File"), new Attachment("fifth", "Fifth Test with Truncation over 25 characters File"), new Attachment("sixth", "Sixth Test File"))) }), IMPORTANT, new Poll("Fourth Test Question", asList(new PollOption[] { new PollOption("Seventh Test Answer"), new PollOption("Eight Test Answer") }), 0)));
    assertTrue(message.equals("Fourth Test Topic"));
    message = createPost(driver, new Post(new Topic(new Forum("Second Test Forum"), "Fourth Test Topic"), "Third Test Post", asList(new Attachment("seventh", "Seventh Test File"), new Attachment("eight", "Eight Test File"), new Attachment("ninth", "Ninth Test File"))));
    assertTrue(message.equals("Third Test Post"));
    message = createPost(driver, new Post(new Topic(new Forum("Second Test Forum"), "Fourth Test Topic"), "Fourth Test Post", asList(new Attachment("ten", "Ten Test File"), new Attachment("eleven", "Eleven Test File"), new Attachment("twelve", "Twelve Test File"))));
    assertTrue(message.equals("Fourth Test Post"));
    message = createPost(driver, new Post(new Topic(new Forum("Second Test Forum"), "Fourth Test Topic"), "Fifth Test with Truncation over 25 characters Post", asList(new Attachment("thirteen", "Thirteen Test File"), new Attachment("fourteen", "Fourteen Test File"), new Attachment("fifteen", "Fifteen Test File"))));
    assertTrue(message.equals("Fifth Test with Truncation over 25 characters Post"));
    message = createPost(driver, new Post(new Topic(new Forum("Second Test Forum"), "Fourth Test Topic"), "Sixth Test Post", asList(new Attachment("sixteen", "Sixteen Test File"), new Attachment("seventeen", "Seventeen Test File"), new Attachment("eighteen", "Eighteen Test File"))));
    assertTrue(message.equals("Sixth Test Post"));
}
Also used : CreateCategory.createCategory(it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory) RemoveCategory.removeCategory(it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory) Category(it.vige.rubia.model.Category) RemovePost.removePost(it.vige.rubia.selenium.forum.action.RemovePost.removePost) VerifyAttachment.getAttachmentsOfCurrentPost(it.vige.rubia.selenium.forum.action.VerifyAttachment.getAttachmentsOfCurrentPost) CreatePost.createPost(it.vige.rubia.selenium.forum.action.CreatePost.createPost) Post(it.vige.rubia.model.Post) Poll(it.vige.rubia.model.Poll) Attachment(it.vige.rubia.model.Attachment) PollOption(it.vige.rubia.model.PollOption) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) Forum(it.vige.rubia.model.Forum) RemoveForum.removeForum(it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum) CreateForum.createForum(it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum) BeforeClass(org.junit.BeforeClass)

Example 13 with Poll

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

the class UpdatePoll method vote.

public static Poll vote(WebDriver driver, Poll poll, int indexVote) {
    List<WebElement> optionsToVoteList = driver.findElements(className(OPTIONS_TO_VOTE_LIST));
    optionsToVoteList.get(indexVote).findElement(xpath("input")).click();
    WebElement voteButton = driver.findElement(className(VOTE_BUTTON));
    voteButton.click();
    Poll updatedPoll = getPollOfCurrentTopic(driver);
    return updatedPoll;
}
Also used : Poll(it.vige.rubia.model.Poll) WebElement(org.openqa.selenium.WebElement)

Example 14 with Poll

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

the class UpdatePoll method updateOptions.

public static Poll updateOptions(WebDriver driver, Poll poll) {
    WebElement updateTopicButton = driver.findElements(xpath("//tbody")).get(2).findElement(id(UPDATE_TOPIC_BUTTON)).findElement(xpath("ul/a[1]"));
    updateTopicButton.click();
    List<PollOption> options = poll.getOptions();
    if (options != null)
        for (int i = 0; i < options.size(); i++) {
            WebElement optionInput = null;
            WebElement optionButton = null;
            optionInput = driver.findElement(id(OPTION_INPUT_TEXT + (i + 1)));
            sleepThread();
            optionInput.clear();
            sleepThread();
            optionInput.sendKeys(options.get(i).getQuestion());
            sleepThread();
            optionButton = driver.findElement(id(UPDATE_OPTION_BUTTON + (i + 1)));
            optionButton.click();
        }
    WebElement submitTopicButton = driver.findElement(id(SUBMIT_TOPIC_BUTTON));
    submitTopicButton.click();
    sleepThread();
    Poll updatedPoll = getPollOfCurrentTopic(driver);
    return updatedPoll;
}
Also used : Poll(it.vige.rubia.model.Poll) PollOption(it.vige.rubia.model.PollOption) WebElement(org.openqa.selenium.WebElement)

Example 15 with Poll

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

the class UpdatePoll method updatePoll.

public static Poll updatePoll(WebDriver driver, Poll poll) {
    WebElement updateTopicButton = driver.findElements(xpath("//tbody")).get(2).findElement(id(UPDATE_TOPIC_BUTTON)).findElement(xpath("ul/a[1]"));
    updateTopicButton.click();
    WebElement questionInput = null;
    questionInput = driver.findElement(id(QUESTION_INPUT_TEXT));
    sleepThread();
    questionInput.clear();
    sleepThread();
    questionInput.sendKeys(poll.getTitle());
    sleepThread();
    WebElement daysInput = driver.findElement(id(DAYS_INPUT_TEXT));
    daysInput.clear();
    daysInput.sendKeys(poll.getLength() + "");
    WebElement submitTopicButton = driver.findElement(id(SUBMIT_TOPIC_BUTTON));
    submitTopicButton.click();
    Poll updatedPoll = getPollOfCurrentTopic(driver);
    return updatedPoll;
}
Also used : Poll(it.vige.rubia.model.Poll) WebElement(org.openqa.selenium.WebElement)

Aggregations

Poll (it.vige.rubia.model.Poll)37 PollOption (it.vige.rubia.model.PollOption)29 Topic (it.vige.rubia.model.Topic)25 Forum (it.vige.rubia.model.Forum)23 Post (it.vige.rubia.model.Post)21 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)21 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)20 Attachment (it.vige.rubia.model.Attachment)19 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)19 Category (it.vige.rubia.model.Category)14 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)14 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)12 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)12 BeforeClass (org.junit.BeforeClass)11 WebElement (org.openqa.selenium.WebElement)10 Test (org.junit.Test)9 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)8 VerifyPoll.getPollOfCurrentTopic (it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic)8 CreatePoll.addPoll (it.vige.rubia.selenium.forum.action.CreatePoll.addPoll)6 RemovePoll.removePoll (it.vige.rubia.selenium.forum.action.RemovePoll.removePoll)6