/** * Run the boolean disabled() method test. * * @throws Exception */ @Test public void testIsDisabled() throws Exception { WebElement mockedEl = Mockito.mock(WebElement.class); final ExtJSComponent cmp_result = new ExtJSComponent(driver, cmpIdBy); Mockito.when(js.executeScript(Mockito.contains("disabled"), Mockito.anyVararg())) .thenReturn(Boolean.TRUE); assertTrue(cmp_result.isDisabled()); }
/** * Run the boolean evalNullComponent(String) method test. return false * * @throws Exception */ @Test public void testEvalNullComponent_false() throws Exception { final ExtJSComponent cmp_result = new ExtJSComponent(driver, cmpIdBy); Mockito.when(js.executeScript(Mockito.contains("var extCmp = Ext.getCmp"))) .thenReturn("something"); final boolean result = cmp_result.execScriptOnExtJSCmpReturnIsNull(cmp_result.getExpression()); assertEquals(false, result); }
/** * Run the String getElDom() method test. * * @throws Exception */ @Test public void testGetElDom() throws Exception { WebElement mockedEl = Mockito.mock(WebElement.class); ByExtJsGetCmp by = cmpIdBy; Mockito.when(by.findElement(driver)).thenReturn(mockedEl); final ExtJSComponent cmp_result = new ExtJSComponent(driver, by); assertNotNull(cmp_result); Mockito.when(((JavascriptExecutor) driver).executeScript(Mockito.contains("getEl().dom"))) .thenReturn(mockedEl); assertEquals(mockedEl, cmp_result.getElDom()); }
private void assertAuthenticationRequired(int expectedStatusCode, String... expectedRealm) throws IOException, ServletException { if (expectedRealm.length == 0) { expectedRealm = new String[] {"PicketLink Test DIGEST Realm"}; } Mockito.verify(this.response) .setHeader( eq("WWW-Authenticate"), Mockito.contains("Digest realm=\"" + expectedRealm[0] + "\"")); Mockito.verify(this.response).sendError(expectedStatusCode); Mockito.verify(this.filterChain, times(0)) .doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class)); }
@Before public void setUp() throws Exception { driver = Mockito.mock( WebDriver.class, Mockito.withSettings().extraInterfaces(JavascriptExecutor.class)); js = (JavascriptExecutor) driver; // Global Mocks Mockito.when(js.executeScript(Mockito.contains("Ext.Ajax.isLoading()"))) .thenReturn(Boolean.FALSE); byExtJsGetCmp = new ByExtJsGetCmp(driver); WebElement mockedEl = Mockito.mock(WebElement.class); cmpIdBy = byExtJsGetCmp.byExtJsGetCmp("cmp_id"); Mockito.when(cmpIdBy.findElement(driver)).thenReturn(mockedEl); }