Discussion:
Problem binding Base abstract class
Nandish MC
2017-02-27 02:45:39 UTC
Permalink
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
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/5da962c5-74da-466d-b96f-53cb647a0eb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Stephan Classen
2017-02-27 06:01:53 UTC
Permalink
So far this code looks correct. Can you also provide some of the test methods. Maybe something is hiding there.
Post by Nandish MC
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
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/5da962c5-74da-466d-b96f-53cb647a0eb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
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/644FC308-ACCF-4D20-AC7E-B3C93DE30A55%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.
Nandish MC
2017-02-27 20:46:40 UTC
Permalink
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
Post by Stephan Classen
So far this code looks correct. Can you also provide some of the test
methods. Maybe something is hiding there.
Post by Nandish MC
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{
Post by Nandish MC
{ }
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
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.
Stephan Classen
2017-02-27 22:17:41 UTC
Permalink
I see in you code how you construct the injector. But I never see you
making use of it.
I am not familiar with the Selenium library. Does it make use of the
injector in the SeleniumTest.getCurrentPage() method?
I rather doubt that Selenium will use you injector. So where do you use
the injector?
Post by Nandish MC
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
*/
@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
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
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 {
void setUp() throws Exception { injector =
protected void configure() {
System.out.println("configuriung");
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
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
<https://groups.google.com/d/msgid/google-guice/43253ec2-1e7e-401d-99dd-d429f2d14a0d%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
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/34fec307-4722-c48f-ff44-343de6609986%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.
Nandish Chikkabasavaraju
2017-02-27 23:38:36 UTC
Permalink
No Selenium test is not using injector.

I am in assumption when suite @beforeClass method is executed to bind, it will have Page bound to ProjPage.

How do I need to use the injector in this case?

Between I am new to Guice.
I see in you code how you construct the injector. But I never see you making use of it.
I am not familiar with the Selenium library. Does it make use of the injector in the SeleniumTest.getCurrentPage() method?
I rather doubt that Selenium will use you injector. So where do you use the injector?
Post by Nandish MC
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
*/
@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
Post by Stephan Classen
So far this code looks correct. Can you also provide some of the test methods. Maybe something is hiding there.
Post by Nandish MC
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 a topic in the Google Groups "google-guice" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-guice/Kema1MvYHtg/unsubscribe.
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/34fec307-4722-c48f-ff44-343de6609986%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.
--
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
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/4613CA3C-987E-4252-A597-141D2AB0D827%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Stephan Classen
2017-02-27 23:55:54 UTC
Permalink
I guess you could do i the following way:

1. make the static injector field on SeleniumSuite public (or package
private if all classes reside in the same package)

2. change the following implementation

public abstract class ProjTest extends SeleniumTest {
@Override
public Page getCurrentPage() {
return SeleniumSuite.injector.get(Page.class)
}
}


But I am not sure as I couldn't find the implementations of
SeleniumSuite and SeleniumTest on the Internet. If theses are not
classes from the selenium library then you should have provided them in
your code snippets for completeness...
Post by Nandish Chikkabasavaraju
No Selenium test is not using injector.
it will have Page bound to ProjPage.
How do I need to use the injector in this case?
Between I am new to Guice.
I see in you code how you construct the injector. But I never see you making use of it.
I am not familiar with the Selenium library. Does it make use of the
injector in the SeleniumTest.getCurrentPage() method?
I rather doubt that Selenium will use you injector. So where do you use the injector?
Post by Nandish MC
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
*/
@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
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
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 {
void setUp() throws Exception { injector =
protected void configure() {
System.out.println("configuriung");
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
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
<https://groups.google.com/d/msgid/google-guice/43253ec2-1e7e-401d-99dd-d429f2d14a0d%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
-- You received this message because you are subscribed to a topic in
the Google Groups "google-guice" group. To unsubscribe from this
topic, visit
https://groups.google.com/d/topic/google-guice/Kema1MvYHtg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
https://groups.google.com/group/google-guice. To view this discussion
on the web visit
https://groups.google.com/d/msgid/google-guice/34fec307-4722-c48f-ff44-343de6609986%40gmx.ch
<https://groups.google.com/d/msgid/google-guice/34fec307-4722-c48f-ff44-343de6609986%40gmx.ch?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
-- 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
https://groups.google.com/group/google-guice. To view this discussion
on the web visit
https://groups.google.com/d/msgid/google-guice/4613CA3C-987E-4252-A597-141D2AB0D827%40gmail.com
<https://groups.google.com/d/msgid/google-guice/4613CA3C-987E-4252-A597-141D2AB0D827%40gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
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/123018ac-eebc-31c1-d2bb-0b1672daa7ea%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.
Nandish Chikkabasavaraju
2017-03-01 04:23:47 UTC
Permalink
Thanks Stephen, that worked. Appreciate your help.

- Nandish

Sent from my iPhone
1. make the static injector field on SeleniumSuite public (or package private if all classes reside in the same package)
2. change the following implementation
public abstract class ProjTest extends SeleniumTest {
@Override
public Page getCurrentPage() {
return SeleniumSuite.injector.get(Page.class)
}
}
But I am not sure as I couldn't find the implementations of SeleniumSuite and SeleniumTest on the Internet. If theses are not classes from the selenium library then you should have provided them in your code snippets for completeness...
Post by Nandish Chikkabasavaraju
No Selenium test is not using injector.
How do I need to use the injector in this case?
Between I am new to Guice.
I see in you code how you construct the injector. But I never see you making use of it.
I am not familiar with the Selenium library. Does it make use of the injector in the SeleniumTest.getCurrentPage() method?
I rather doubt that Selenium will use you injector. So where do you use the injector?
Post by Nandish MC
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
*/
@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
Post by Stephan Classen
So far this code looks correct. Can you also provide some of the test methods. Maybe something is hiding there.
Post by Nandish MC
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 a topic in the Google Groups "google-guice" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-guice/Kema1MvYHtg/unsubscribe.
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/123018ac-eebc-31c1-d2bb-0b1672daa7ea%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.
--
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
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/1C7A1770-FBEE-4EA1-9676-3A0FD9E9D254%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...