Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   How to invoke the variables from first class and second class to third class in java (https://www.askmehelpdesk.com/showthread.php?t=815601)

  • Aug 26, 2015, 10:44 AM
    shreyas007
    How to invoke the variables from first class and second class to third class in java
    I need to invoke the class1 and class2 variable to class3.
    class1 and class2 contain only variable , no methods.

    I am not able execute my program.

    My code contain some selenium scripts also

    My code as follows

    package TestObjects;


    import org.openqa.selenium.By;


    public class class1 {





    public By username=By.xpath(".//*[@id='username']");

    public By password=By.xpath(".//*[@id='password']");

    public By signinbutton=By.xpath(".//*[@id='sign-in-button']");



    }




    package TestObjects;


    import org.openqa.selenium.By;






    public class class2 {

    public By myaccountdropdown=By.xpath(".//*[@id='homepage']/nav/ul/li[8]/div[1]/span[3]");

    public By signin=By.xpath(".//*[@id='homepage']/nav/ul/li[8]/div[2]/div[1]/div[1]/button");


    }




    package Pages;


    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;


    import TestObjects.HomePage_Locators;
    import TestObjects.LoginPage_Locators;




    public class class3 {
    public WebDriver driver;

    public void account_signin()

    {
    class1 obj1=new class1();
    class2 obj2=new class2();



    driver.findElement(myaccountdropdown).click();

    driver.findElement(signin).click();

    driver.findElement(username).sendKeys("nousername" );

    driver.findElement(password).sendKeys("nopassword" );

    driver.findElement(signinbutton).click();

    }






    }

  • All times are GMT -7. The time now is 05:53 PM.