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;
}
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;
}
Aggregations