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