com.steps.deviantarttestproject.Steps.java Source code

Java tutorial

Introduction

Here is the source code for com.steps.deviantarttestproject.Steps.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.steps.deviantarttestproject;

import com.pageobject.deviantarttestproject.*;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

/**
 *
 * @author stassko
 */
public class Steps {
    private static final Logger logger = Logger.getLogger(Steps.class.getName());

    private WebDriver driver;

    public void initBrowser() {
        driver = new FirefoxDriver();
        driver.manage().timeouts().pageLoadTimeout(500, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        logger.info("Browser started");
    }

    public void closeDriver() {
        driver.quit();
    }

    public void loginDeviantart(String username, String password) {
        LoginPage loginPage = new LoginPage(driver);
        loginPage.openPage();
        loginPage.login(username, password);
    }

    public void searchDeviantart(String smth) {
        MainPage mainpage = new MainPage(driver);
        mainpage.openPage();
        mainpage.searchDA(smth);
    }

    public void GoToMyProfile() {
        MainPage mainpage = new MainPage(driver);
        mainpage.openPage();
        mainpage.GoToMP();
    }

    public void GoToChatPage() {
        MainPage mainpage = new MainPage(driver);
        mainpage.openPage();
        mainpage.GoToChat();
    }

    public void GoToLogOutPage() {
        MainPage mainpage = new MainPage(driver);
        mainpage.openPage();
        mainpage.GoToLogout();
    }

    public void GoToForumPage() {
        MainPage mainpage = new MainPage(driver);
        mainpage.openPage();
        mainpage.GoToForumWindow();
    }

    public void GoToJournalPage() {
        MainPage mainpage = new MainPage(driver);
        mainpage.openPage();
        mainpage.GoToJournalWindow();
    }

    public void GoToShopPage() {
        MainPage mainpage = new MainPage(driver);
        mainpage.openPage();
        mainpage.GoToShop();
    }

    public void createChatR(String name, String description) {
        ChatPage chatpage = new ChatPage(driver);
        chatpage.openPage();
        chatpage.createChatroom(name, description);
    }

    public void deleteChatR() {
        ChatPage chatpage = new ChatPage(driver);
        chatpage.openPage();
        chatpage.deleteChatroom();
    }

    public boolean isLoggedIn() {
        LoginPage loginPage = new LoginPage(driver);
        return (loginPage.getLoggedInUserName());
    }

    public boolean isLoggedOut() {
        LogoutPage logoutpage = new LogoutPage(driver);
        return (logoutpage.isLogOut());
    }

    public boolean isForumWindow() {
        ForumPage forumpage = new ForumPage(driver);
        return (forumpage.isTopic());
    }

    public boolean isJournalWindow() {
        JournalPage journalpage = new JournalPage(driver);
        return (journalpage.isJournal());
    }

    public boolean isSearched() {
        MainPage mainpage = new MainPage(driver);
        return (mainpage.isSearchSMTH());
    }

    public boolean isSearchedMult() {
        MainPage mainpage = new MainPage(driver);
        return (mainpage.isSearchSMTHMult());
    }

    public boolean isGoToMP() {
        ProfilePage profilepage = new ProfilePage(driver);
        return (profilepage.isToMP());
    }

    public boolean isGoToChat() {
        ChatPage chatpage = new ChatPage(driver);
        return (chatpage.isToChat());
    }

    public boolean isGoToShop() {
        ShopPage shoppage = new ShopPage(driver);
        return (shoppage.isToShop());
    }

    public boolean isCreateChatroom() {
        ChatPage chatpage = new ChatPage(driver);
        return (chatpage.isCreateChat());
    }

    public boolean isDeleteChatroom() {
        ChatPage chatpage = new ChatPage(driver);
        return (chatpage.isDeleteChat());
    }

}