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...
On 28.02.2017 00:38, Nandish Chikkabasavaraju wrote:
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.
On Feb 27, 2017, at 5:17 PM, Stephan Classen <st.clas...@gmx.ch
<mailto:st.clas...@gmx.ch>> wrote:
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?
On 27.02.2017 21:46, Nandish MC wrote:
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
<gowda....@gmail.com <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
google-guice+unsubscr...@googlegroups.com
<mailto:google-guice+unsubscr...@googlegroups.com>. To post to this
group, send email to google-guice@googlegroups.com
<mailto:google-guice@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
<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
google-guice+unsubscr...@googlegroups.com
<mailto:google-guice+unsubscr...@googlegroups.com>. To post to this
group, send email to google-guice@googlegroups.com
<mailto:google-guice@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
<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
google-guice+unsubscr...@googlegroups.com
<mailto:google-guice+unsubscr...@googlegroups.com>. To post to this
group, send email to google-guice@googlegroups.com
<mailto:google-guice@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
<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+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@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.