@Test public void testEphemeralMutableSettingsAreBound() throws IOException { Settings s = new SettingsBuilder().build(); Dependencies deps = Dependencies.builder().useMutableSettings().add(s, Namespace.DEFAULT).build(); MutableSettings a = deps.getInstance(MutableSettings.class); MutableSettings b = deps.getInstance(MutableSettings.class); assertNotSame(a, b); a.setInt("foo", 23); assertEquals(23, (int) a.getInt("foo")); assertNull(b.getString("foo")); }
/** * Instantiate an object,using Selenium's PageFactory, and injecting any fields annotated with * @Inject by Guice. * * <p>This is useful if you have caused the browser page to refresh and you need to rebuild a * model of the window's page. * * @param <T> A type * @param type The object to create * @return A new instance of this type */ public <T> T instantiate(Class<T> type) { Checks.notNull("type", type); T result = PageFactory.initElements(driver, type); deps.injectMembers(result); return result; }