0

enter image description here

package tests;    
import java.net.MalformedURLException;    
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;    
import junit.framework.Assert;
import pages.DashBoardPage;
import pages.LoginPage;

public class LoginPageTest extends LoginPage {

    //DashBoardPage dashBoardPage = new DashBoardPage(driver);


     public static WebDriver driver;
    LoginPage loginPage; 
    DashBoardPage ds;
     public LoginPageTest() { 
         super(driver); 
         ds=new DashBoardPage(driver);

         }


    @BeforeTest
    public void setup() throws MalformedURLException {

        intialization();
    }



    /*@Test(priority = 1)
    public void LoginPageTitleTest() {

        Assert.assertEquals(getPageTitle(), "verizon");

    }*/

    // 07/02/2019
    @Test(priority =2)
    public void VerizonlogoTest() throws InterruptedException {
        Thread.sleep(5000);
        try{
            if(UserID.isDisplayed())
            {
              clickUserID();
              clickPassword();
              clickLoginBtn();
            }

        }
        catch(Exception e)
        {
            System.out.println("Clicking on I Agree Button");
        }
        finally{
            clickAgree();
        }
        explicitWait(ds.dashBoard);
        Assert.assertTrue(ds.getDashBoardTitle().equals("Dashboard"));
        /*driver.findElement(By.xpath("//android.widget.EditText[@resource-id='USER']")).sendKeys("jomonli");
        driver.findElement(By.xpath("//android.widget.EditText[@resource-id='PASSWORD']")).sendKeys("Brownlenovo5@");
        driver.findElement(By.xpath("//android.view.View[@resource-id='btnLogin']")).isEnabled();
        Assert.assertTrue(driver.findElement(By.xpath("//android.view.View[@text='Verizon Mobile Single Sign on']")).isDisplayed());
        Assert.assertTrue(driver.findElement(By.xpath("//android.view.View[@text='First time user, click here to activate.']")).isEnabled());
        */
        //LoginPage loginPage = PageFactory.initElements(driver, LoginPage.class);
        //isElementVisible(loginPage.getVerizonLogo());
        //loginPage.clickUserID();

    }

    /*
     * @Test(priority = 2, description = "Logo is present Test") public boolean
     * VerizonLogoTest() { //boolean logo = loginPage.VerizonLogo();
     * //Assert.assertTrue(logo); //return logo; }
     * 
     * @Test(priority = 3, description = "LoginBtn is clickable and enabled")
     * public boolean LoginBtnClickableTest() { //boolean clickable =
     * loginPage.LoginBtnClickable(); //Assert.assertTrue(clickable); //return
     * clickable; }
     */

    //@Test(priority = 4, description = "User is able to login succesfully with valid credentials")
    public void LoginTest() {
        // dashBoardPage = loginPage.Login(prop.getProperty("userID"),
        // prop.getProperty("password"));
    }

    /*
     * @Test(description = "FirstTimeUserLink is clickable and enabled") public
     * boolean FirstTimeUserLinkClickableTest() { boolean clickable =
     * loginPage.FirstTimeUserLinkClickable(); Assert.assertTrue(clickable);
     * return clickable; }
     */

    @AfterTest
    public void teardown() {

        driver.quit();
}


//  private Object () {
//      // TODO Auto-generated method stub
//      return null;
//  }
}

Dashboard Page

package pages;    
import java.util.Calendar;
import java.util.List;    
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;    
import base.BaseClass;
import base.GenericMethods;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.pagefactory.AndroidFindBy;

public class DashBoardPage extends GenericMethods{

    WebDriver driver;

    public DashBoardPage(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver, this);
    }


    private int today;

    //ActionsBar


    //Title
    @FindBy(xpath="//android.view.View[resource-id='jobPageTitle']")
    public WebElement dashBoard;

    public WebElement getDashBoardTitle() {
        click(dashBoard,"");
        return dashBoard;
        //return explicitWait(dashBoard);
    }


    //Search
    @FindBy(xpath="//android.widget.Image[text()[contains(.,'searchiconnew')]]") 
    private MobileElement searchIcon;

    public MobileElement clickSearchIcon() {
        click(searchIcon,"");
        return searchIcon;
    }

    @FindBy(xpath="//android.widget.Image[text()[contains(.,'search_cancel')]]") 
    private MobileElement searchIconCancelBtn;

    public MobileElement clickSearchIconCancelBtn() {
        click (searchIconCancelBtn,"");
        return searchIconCancelBtn;
    }

    @FindBy(id="txtSearchBtn")
    private MobileElement dropDown;

    public MobileElement clickDropDown() {
        click(dropDown,"");
        return dropDown;
    }

    @FindBy(id="txtSearch")
    private MobileElement searchBar;

    public MobileElement clickSearchBar() {
        click(searchBar,"");
        return searchBar;
    }


    //Help Logo
    @FindBy(id="helpLogo")
    private MobileElement helpLogo;

    public MobileElement clickHelpLogo() {
        click(helpLogo,"");
        return helpLogo;
    }

    @FindBy(xpath="//android.widget.Button[text()[contains(.,'OK')]]")  
    private MobileElement helpLogoOKBtn;

    public MobileElement clickHelpLogoBtn() {
        click(helpLogoOKBtn,"");
        return helpLogoOKBtn;
    }


    //DropIcon
    @FindBy(xpath="//android.widget.Image[text()[contains(.,'dropingIcon')]]")
    private MobileElement dropIcon;

    public MobileElement clickDropIcon() {
        click(dropIcon,"");
        return dropIcon;
    }

    @FindBy(xpath="//android.view.View[text()[contains(.,'Send Log')]]")
    private MobileElement dropiconSendLog;

    public MobileElement clickDropIconSendLog() {
        click(dropiconSendLog,"");
        return dropiconSendLog;
    }

    //
    @FindBy(xpath="//android.view.View[text()[contains(.,'Logout')]]")
    private MobileElement dropiconLogOut;

    public MobileElement clickDropIconLogout() {
        click(dropiconLogOut,"");
        return dropiconLogOut;
    }


    //Previous and Next
    @FindBy(xpath="//android.view.View[text()[contains(.,' Previous')]]")
    private MobileElement previousBtn;

    public MobileElement clickOnPreviousBtn() {
        click (previousBtn,"");
        return previousBtn;
    }

    @FindBy(xpath="//android.view.View[text()[contains(.,' Next')]]")
    private MobileElement nextBtn;

    public MobileElement clickOnNextBtn() {
        click(nextBtn,"");
        return nextBtn;
    }


    //Month
    @FindBy(id="calMonth")
    private MobileElement monthName;

    public MobileElement getMonthName() {
        click(monthName,"");
        return monthName;
    }


    @AndroidFindBy(id="next")
    private MobileElement monthNextBtn;

    public MobileElement clickMonthNextBtn() {
        click(monthNextBtn,"");
        return monthNextBtn;
    }


    //Refresh Calender
    @FindBy(id="RefreshCalBtn")
    private MobileElement refreshCalenderBtn;

    public MobileElement clickRefreshCalenderBtn() {
        click(refreshCalenderBtn,"");
        return refreshCalenderBtn;
    }

    /*
    public String getTitle(){
        return driver.getTitle();
    }

    public void clicksearch(String search){
        searchIcon.sendKeys(search);
    }

    public void cancelSeacrhBar(){
        searchIconCancelBtn.click();
    }


     * public void optionsSearchDropdown(){ driver.
     * findElementByAndroidUIAutomator("new UiScrollable(newUiSelector()).scrollIntoView(new UiSelector().text(\"E Glossary\"));"
     * ).click(); }

    public void getTextDropDown(){
        Select dropdown = new Select(driver.findElement(By.id("txtSearchBtn")));
        List <WebElement> dd = dropdown.getOptions();
        System.out.println(dd.size());
        for(int i = 0; i<= dd.size();i++){
            System.out.println(dd.get(i).getText());
        }
    }

    public void VerifyOptionInDropDown() {
        Select dropdown1 = new Select(driver.findElement(By.id("txtSearchBtn")));

        String[] exp = { "Document", "E Glossary" };
        List<WebElement> dd1 = dropdown1.getOptions();
        int i = 0;
        for (WebElement we : dd1) {

            if (we.getText().equals(exp[i])) {

                System.out.println("Matched :: " + we.getText());

            } else {
                System.out.println("Not Matched  :: " + we.getText());
            }
            i++;
        }

    }

    public void clickHelpIcon(){
        helpLogo.click();
    Alert alert =   driver.switchTo().alert();
    alert.accept();


    }

    //If Alert is present
    public boolean isAlertPresent() 
    { 
        try 
        { 
            driver.switchTo().alert(); 
            return true; 
        }   // try 
        catch (NoAlertPresentException Ex) 
        { 
            return false; 
        }   // catch 
    }   // isAlertPresent()


    public boolean DropIconOptionsSendLogEnabled(){
        dropIcon.click();
        return dropiconSendLog.isEnabled();
    }

    public boolean DropIconOptionsLogOutEnabled(){
        dropIcon.click();
        return dropiconLogOut.isEnabled();
    }


    public void PreviousBtnEnabled(){
        previousBtn.isEnabled();
    }

    public void NextBtnEnabled(){
        nextBtn.isEnabled();
    }

    public void monthChangesOnNextBtn(){
        Calendar now = Calendar.getInstance();
  //Trying to check if clicking next button actually changes the month
        monthNextBtn.click();
    String monthname= monthName.getText();// clicking on monthname and getting text of it
    {
        if(monthname.equals(now.get(Calendar.MONTH)+2)){//month start from 0 to 11
            System.out.println("Date have changed upon clicking the next button");
        }else{
            System.out.println("Date have not changed upon clicking next button, please check Button");
        }
    }
    }


    //to check calender picker has todays date as default
    public void defaultDate(){
        Calendar now = Calendar.getInstance();
    }

    //check the refresh Calender return to current month and current date
    public void refreshCalenderFunctionality(){
        Calendar now = Calendar.getInstance();
        monthNextBtn.click();
        refreshCalenderBtn.click();
        String month = monthName.getText();
        {
            if (month.equals(now.get(Calendar.MONTH)+1)){
                System.out.println("Refresh Calender button fucntionality is working");
            }else{
                System.out.println("Check Refresh Calender");
            }
        }
    }*/


}

Base Page

package base;    
import java.net.URL;
import java.util.Properties;
import java.util.concurrent.TimeUnit;    
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;   
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class BaseClass {

    public static Properties prop;

    public static WebDriver driver;

    public static URL url;

    public static WebDriver intialization() {


        DesiredCapabilities cap = new DesiredCapabilities();

        cap.setCapability("deviceName", "Galaxy Tab S3");// setting > about
                                                            // phone
        cap.setCapability("udid", "624258263526a1e8");
        // udid is the device name when you press - cmd adb devices
        cap.setCapability("platformName", "Android");
        cap.setCapability("platformVersion", "8.0.0");
        cap.setCapability("appPackage", "com.verizon.launcher.sdnasit");
        cap.setCapability("appActivity", "com.verizon.launcher.webview.WebActivity");
        // cap.setCapability(MobileCapabilityType.APP, "Apk file location
        // C:\\apkfiles\\AndroidUI.apk"
        cap.setCapability("noReset", "True");
        cap.setCapability("automationName", "uiautomator2");

        cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);

        // any application will have app package and app activity
        // download apk info from playstore
        try{

             url = new URL("http://127.0.0.1:4723/wd/hub");
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        driver = new AndroidDriver(url, cap);
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        //LoginPageTest loginPage= new LoginPageTest();

        return driver;

    }


}
  • You forgot to put your LoginPage, cause I do not see it instantiated anywhere. As the error says, searchIcon cannot be set, based on your @FindBy annotation. – Tabla Mihai Jul 11 at 13:47
  • Could you explain what the issue is? And what you've done to try to resolve it? Do you understand what the error message tells you? – corsiKa Jul 11 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.