public abstract class Page extends SelPage
{
   public void logOut() {
        System.out.println("inside Product");
        WebDriverWait wait = new WebDriverWait(getDriver(), getWaitTime());
        WebElement element = 
wait.until(ExpectedConditions.elementToBeClickable(By.id("logout")));
        element.click();

        // this is typically not recommended, but logout is an oddball; 
because
        // we don't know where we're going after logout, we can't do a 
"wait"
        // for something on that page
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            // eat it
        }
    }
}


Class ProjPage extends Page{

 @Override
    public void logOut() {
        System.out.println("Inside Project");
        WebDriverWait wait = new WebDriverWait(getDriver(), getWaitTime());
        WebElement element = 
wait.until(ExpectedConditions.elementToBeClickable(By.id("logout")));
        element.click();

        // this is typically not recommended, but logout is an oddball; 
because
        // we don't know where we're going after logout, we can't do a 
"wait"
        // for something on that page
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            // eat it
        }
    }
}

@RunWith(Suite.class)
@Suite.SuiteClasses({ Login.class, 
    ProjectLogout.class, 
})
public class ProjSeleniumSuite  extends SeleniumSuite {
    
    private static Injector injector;
    /*
     * No code is needed in here. Add new tests to the suite by putting 
them in
     * the @Suite.SuiteClasses() declaration above.
     */

    @BeforeClass
    public static void setUp() throws Exception {
        System.out.println("setting up");
        injector = Guice.createInjector(new AbstractModule() {

            @Override
            protected void configure() {
                System.out.println("configuriung");
                bind(Page.class).to(ProjPage.class);
            }
        });
    }

    @AfterClass
    public static void tearDown() throws Exception {
        System.out.println("tearing down");
        injector = null;
    }
}

public class ProjLogout extends ProjTest {

        /**
         * Log out of the application.
         */
        @Test
        public void logout() {
            System.out.println("inside CBC logout............");
            getCurrentPage().logout();
        }
 }

Class DashboardPage extends Class Page{
{
//inherits Page logout method
methods 1
methods 2
methods 3
 }

public abstract class ProjTest extends SeleniumTest{
       public Page getCurrentPage() {
       try{
            Page dashBoardPage =(Page) super.getCurrentPage(); // This gets 
the Dashboard page instance
        }catch(Exception e){
            setCurrentPage(null);
        }
        return (Page) super.getCurrentPage();
      }
}


Above are the set of classes used, here I am trying to get ProjPage logout 
method to be executed instead of Page.logout() method.

This method is an inherited method for Dashboard Page.

currently, even after binding I see Page.logout() method is executed
 

On Monday, February 27, 2017 at 1:01:58 AM UTC-5, scl wrote:
>
> So far this code looks correct. Can you also provide some of the test 
> methods. Maybe something is hiding there.
>
> Am 27. Februar 2017 03:45:39 MEZ schrieb Nandish MC <[email protected] 
> <javascript:>>:
>>
>> I have multiple hierarchical class like below
>>
>> public abstract class Page extends SelPage
>> {
>> public method 1{}
>> public method 2{}
>> public method 3{}
>> }
>>
>
 

> Class DashboardPage extens Class Page{
>> { }
>>
>> Here I need to bind new Page class
>> Class ProjPage extends Page{
>> public method1{} /* change method implementation 
>> */public method 2{} /* change method implementation 
>> */public method 3{} /* change method implementation */
>> }
>>
>> public class ProjSeleniumSuite extends SeleniumSuite {
>>
>> private static Injector injector;
>>
>> @BeforeClass
>> public static void setUp() throws Exception {
>>     injector = Guice.createInjector(new AbstractModule() {
>>         @Override
>>         protected void configure() {
>>             System.out.println("configuriung");
>>             bind(Page.class).to(ProjPage.class);
>>         }
>>     });
>> }
>> @AfterClass
>> public static void tearDown() throws Exception {
>>     injector = null;
>> }
>>
>> }
>>
>> The above code runs fine..but it is not binding the Page class method 
>> implementation with ProjPage class methods
>> Can i achieve this using Guice binder like above?
>>
>> The thing i need to achieve is, when i instantiate DashboardPage , i want 
>> ProjPage methods to be called instead of Page class methods.
>>
>> Please help
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/43253ec2-1e7e-401d-99dd-d429f2d14a0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to