Guice Novice Error in Using AemLogin of Bobcat through my Java main

397 Views Asked by At

I am new to Bobcat(automated framework for AEM).I am trying to write a sample Java class that could use the AemLogin API through a inject.But I am getting errors. I am unable to clearly understand how to use the Module to bind since there is only one implementation class of AemLogin that i am trying to inject.

import com.cognifide.qa.bb.aem.AemLogin;
   import com.google.inject.Guice;
   import com.google.inject.Inject;
   import com.google.inject.Injector;

   public class BobcatMain {
    @Inject
    private LoginTest loginTest;

    private static  String url ="localhost:4502";
    private static String login ="admin";
    private static String password ="admin";

    public static void main(String[] args)
    {
        Injector injector = Guice.createInjector();
        injector.getInstance(BobcatTest.class).AuthenticateUser();

    }
}

import com.cognifide.qa.bb.aem.AemLogin;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.name.Named;
public class BobcatTest {
    private static  String url ="localhost:4502";
    private static String login ="admin";
    private static String password ="admin";
    private AemLogin aemLogin;

    @Inject
    public BobcatTest(AemLogin aem) {
        this.aemLogin= aem;
         System.out.println(aem);
    }
        public void AuthenticateUser() {
            aemLogin.login(url, login, password);
            System.out.println("Login Successful");
        }
}

When i run the application i get multiple errors

Exception in thread "main" com.google.inject.ConfigurationException: Guice configuration errors:

1) No scope is bound to com.cognifide.qa.bb.guice.ThreadScoped. at com.cognifide.qa.bb.aem.AemAuthCookieFactory.class(AemAuthCookieFactory.java:51) while locating com.cognifide.qa.bb.aem.AemAuthCookieFactory 2) No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=author.login) was bound. while locating java.lang.String annotated with @com.google.inject.name.Named(value=author.login) 3) No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=author.password) was bound. while locating java.lang.String annotated with @com.google.inject.name.Named(value=author.password) 4) No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=author.url) was bound. while locating java.lang.String annotated with @com.google.inject.name.Named(value=author.url) 5) No implementation for org.openqa.selenium.WebDriver was bound. while locating org.openqa.selenium.WebDriver

5 errors at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004) at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:961) at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013) at com.test.diageo.BobcatMain.main(BobcatMain.java:19)

0

There are 0 best solutions below