I am automating a webform, and this is what I've coded so far. I am curious if you find the code good and readable. But most important to me is to get some feedback for learning purposes.
The remove account page:
public class RemoveAccountsPage extends Page {
private Boolean accountsToRemove() {
by = By.className("zero-results-filter");
return ((elementExists(by)) ? true : false);
}
private void selectAllAccounts() {
by = By.id("accounts-select-all");
element = waitForPresenceOfElement(by);
element.click();
}
private void clickRemoveButton() {
by = By.id("account-delete");
element = waitForPresenceOfElement(by);
element.click();
}
private void confirmRemovingAccounts() {
by = By.id("confirm");
element = waitForPresenceOfElement(by);
element.click();
//driver.findElement(By.id("NO_DEAL_VIA_MP")).click()
}
public void removeAccounts() throws Exception {
String request = Page.URL + "/hu/accounts/index.html";
goToWebPage(request);
Boolean result = accountsToRemove();
if(result == false) {
selectAllAccounts();
clickRemoveButton();
confirmRemovingAccounts();
}
Thread.sleep(1000);
}
}
Main class:
public class AccountManager {
public static void main(String args[]) throws Exception {
Bot bot = new Bot();
bot.setUp();
........
RemoveAccountsPage removeAccountsPage = new
RemoveAccountsPage();
removeAccountsPage.removeAccounts();
........
bot.tearDown();
}
}