Search in sources :

Example 36 with Poll

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

the class CreateTopic method createTopic.

public static String createTopic(WebDriver driver, Topic topic) {
    WebElement home = driver.findElement(linkText(HOME_LINK));
    home.click();
    WebElement forumEl = driver.findElement(linkText(topic.getForum().getName()));
    forumEl.click();
    WebElement createTopic = driver.findElement(xpath(CREATE_TOPIC_LINK));
    createTopic.click();
    WebElement subjectInput = driver.findElement(id(SUBJECT_INPUT_TEXT));
    sleepThread();
    subjectInput.sendKeys(topic.getSubject());
    switchFrame(driver);
    sleepThread();
    WebElement bodytInput = driver.findElement(cssSelector("body"));
    bodytInput.sendKeys(topic.getPosts().get(0).getMessage().getText());
    driver.switchTo().defaultContent();
    sleepThread();
    WebElement topicTypeInput = null;
    topicTypeInput = driver.findElements(xpath("//input[@type='radio']")).get(topic.getType().getValue());
    topicTypeInput.click();
    sleepThread();
    Poll poll = topic.getPoll();
    if (poll != null)
        createOptions(driver, poll);
    sleepThread();
    addAttachments(driver, topic.getPosts().get(0));
    sleepThread();
    WebElement operationButton = driver.findElement(id(SUBMIT_BUTTON));
    operationButton.click();
    sleepThread();
    if (topic.getPosts().size() > 1) {
        for (int i = 1; i < topic.getPosts().size(); i++) {
            Post post = topic.getPosts().get(i);
            if (post.getTopic() == null)
                post.setTopic(topic);
            createPost(driver, post);
        }
    }
    sleepThread();
    WebElement resultCreateTopic = driver.findElement(linkText(topic.getSubject()));
    String updatedTopic = resultCreateTopic.getText();
    return updatedTopic;
}
Also used : Post(it.vige.rubia.model.Post) CreatePost.createPost(it.vige.rubia.selenium.forum.action.CreatePost.createPost) Poll(it.vige.rubia.model.Poll) WebElement(org.openqa.selenium.WebElement)

Example 37 with Poll

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

the class UpdatePoll method deleteOptions.

public static Poll deleteOptions(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 optionButton = null;
            optionButton = driver.findElement(xpath("//input[@value='" + options.get(i).getQuestion() + "']/../input[@value='" + DELETE_OPTION_BUTTON + "']"));
            optionButton.click();
        }
    WebElement submitTopicButton = driver.findElement(id(SUBMIT_TOPIC_BUTTON));
    submitTopicButton.click();
    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)

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