List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException()
From source file:com.comcast.magicwand.drivers.AbstractPhoenixDriverTest.java
License:Apache License
@Test public void testTakeScreenshotWebDriverException() { final boolean expected = false; boolean actual; final String input = "filepath"; when(((TakesScreenshot) this.webDriverMock).getScreenshotAs((OutputType<File>) Mockito.any())) .thenThrow(new WebDriverException()); actual = this.myTestObj.takeScreenshot(input); Assert.assertEquals(expected, actual); }
From source file:com.liferay.cucumber.selenium.WebDriverHelper.java
License:Open Source License
public static String getConfirmation(WebDriver webDriver) { webDriver.switchTo();/*from w w w . ja v a 2 s . c o m*/ WebDriverWait webDriverWait = new WebDriverWait(webDriver, 1); try { Alert alert = webDriverWait.until(ExpectedConditions.alertIsPresent()); String confirmation = alert.getText(); alert.accept(); return confirmation; } catch (Exception e) { throw new WebDriverException(); } }
From source file:net.mindengine.galen.tests.specs.reader.ObjectDefinitionReaderErrorHandlingTest.java
License:Apache License
@Test(expectedExceptions = { WebDriverException.class }) public void shouldHandleRethrowWebDriverError() throws Exception { // given/*from w ww.ja va 2 s . c o m*/ PageSpecReader pageSpecReader = mock(PageSpecReader.class); WebDriver driver = mock(WebDriver.class); VarsContext varsContext = mock(VarsContext.class); SeleniumPage seleniumPage = new SeleniumPage(driver); PageSpec pageSpec = new PageSpec(); StateObjectDefinition stateObjectDefinition = new StateObjectDefinition(pageSpec, pageSpecReader); String line = "myObject-* css .avc"; Place place = new Place("", 1); // when when(driver.findElements(any(By.class))).thenThrow(new WebDriverException()); when(pageSpecReader.getPage()).thenReturn(seleniumPage); when(varsContext.process(line)).thenReturn(line); stateObjectDefinition.process(varsContext, line, place); }
From source file:org.cerberus.engine.gwt.ControlServiceTest.java
License:Open Source License
@Ignore @Test//w w w .ja va 2 s. c om public void testDoControlElementPresentWhenWebDriverException() { String property = "id=test"; String value = "null"; String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*"; Identifier identifier = new Identifier(); identifier.setIdentifier("id"); identifier.setLocator("test"); TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution(); tcsace.setControl("verifyElementPresent"); tcsace.setValue1(property); tcsace.setValue2(value); tcsace.setFatal("Y"); tCExecution.setSession(session); TestCaseStepExecution tcse = new TestCaseStepExecution(); tcse.settCExecution(tCExecution); TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution(); tcsae.setTestCaseStepExecution(tcse); tcsace.setTestCaseStepActionExecution(tcsae); when(webdriverService.isElementPresent(tCExecution.getSession(), identifier)) .thenThrow(new WebDriverException()); this.controlService.doControl(tcsace); Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg)); Assert.assertEquals("CA", tcsace.getReturnCode()); Assert.assertEquals("Y", tcsace.getFatal()); }
From source file:org.cerberus.engine.gwt.ControlServiceTest.java
License:Open Source License
@Ignore @Test/* w ww .j ava2 s. c o m*/ public void testDoControlElementNotPresentWhenWebDriverException() { String property = "id=test"; String value = "null"; String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*"; Identifier identifier = new Identifier(); identifier.setIdentifier("id"); identifier.setLocator("test"); TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution(); tcsace.setControl("verifyElementNotPresent"); tcsace.setValue1(property); tcsace.setValue2(value); tcsace.setFatal("Y"); TestCaseStepExecution tcse = new TestCaseStepExecution(); tcse.settCExecution(tCExecution); TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution(); tcsae.setTestCaseStepExecution(tcse); tcsace.setTestCaseStepActionExecution(tcsae); when(webdriverService.isElementPresent(session, identifier)).thenThrow(new WebDriverException()); this.controlService.doControl(tcsace); Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg)); Assert.assertEquals("CA", tcsace.getReturnCode()); Assert.assertEquals("Y", tcsace.getFatal()); }
From source file:org.cerberus.engine.gwt.ControlServiceTest.java
License:Open Source License
@Ignore @Test/*from w ww. jav a 2 s.c om*/ public void testDoControlElementNotVisibleWhenWebDriverException() { String property = "id=test"; String value = "null"; String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*"; Identifier identifier = new Identifier(); identifier.setIdentifier("id"); identifier.setLocator("test"); TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution(); tcsace.setControl("verifyElementNotVisible"); tcsace.setValue1(property); tcsace.setValue2(value); tcsace.setFatal("Y"); TestCaseStepExecution tcse = new TestCaseStepExecution(); tcse.settCExecution(tCExecution); TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution(); tcsae.setTestCaseStepExecution(tcse); tcsace.setTestCaseStepActionExecution(tcsae); when(webdriverService.isElementPresent(session, identifier)).thenThrow(new WebDriverException()); this.controlService.doControl(tcsace); Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg)); Assert.assertEquals("CA", tcsace.getReturnCode()); Assert.assertEquals("Y", tcsace.getFatal()); }
From source file:org.cerberus.service.ControlServiceTest.java
License:Open Source License
@Ignore @Test/*from w w w . ja va 2 s . c om*/ public void testDoControlElementPresentWhenWebDriverException() { String property = "id=test"; String value = "null"; String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*"; TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution(); tcsace.setControlType("verifyElementPresent"); tcsace.setControlProperty(property); tcsace.setControlValue(value); tcsace.setFatal("Y"); tCExecution.setSelenium(selenium); TestCaseStepExecution tcse = new TestCaseStepExecution(); tcse.settCExecution(tCExecution); TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution(); tcsae.setTestCaseStepExecution(tcse); tcsace.setTestCaseStepActionExecution(tcsae); when(seleniumService.isElementPresent(tCExecution.getSelenium(), anyString())) .thenThrow(new WebDriverException()); this.controlService.doControl(tcsace); Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg)); Assert.assertEquals("CA", tcsace.getReturnCode()); Assert.assertEquals("Y", tcsace.getFatal()); }
From source file:org.cerberus.service.ControlServiceTest.java
License:Open Source License
@Ignore @Test//from w ww.j av a 2 s . c o m public void testDoControlElementNotPresentWhenWebDriverException() { String property = "id=test"; String value = "null"; String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*"; TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution(); tcsace.setControlType("verifyElementNotPresent"); tcsace.setControlProperty(property); tcsace.setControlValue(value); tcsace.setFatal("Y"); TestCaseStepExecution tcse = new TestCaseStepExecution(); tcse.settCExecution(tCExecution); TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution(); tcsae.setTestCaseStepExecution(tcse); tcsace.setTestCaseStepActionExecution(tcsae); when(seleniumService.isElementPresent(selenium, anyString())).thenThrow(new WebDriverException()); this.controlService.doControl(tcsace); Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg)); Assert.assertEquals("CA", tcsace.getReturnCode()); Assert.assertEquals("Y", tcsace.getFatal()); }
From source file:org.cerberus.service.ControlServiceTest.java
License:Open Source License
@Ignore @Test//from w w w . j a v a 2s . com public void testDoControlElementNotVisibleWhenWebDriverException() { String property = "id=test"; String value = "null"; String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*"; TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution(); tcsace.setControlType("verifyElementNotVisible"); tcsace.setControlProperty(property); tcsace.setControlValue(value); tcsace.setFatal("Y"); TestCaseStepExecution tcse = new TestCaseStepExecution(); tcse.settCExecution(tCExecution); TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution(); tcsae.setTestCaseStepExecution(tcse); tcsace.setTestCaseStepActionExecution(tcsae); when(seleniumService.isElementPresent(selenium, anyString())).thenThrow(new WebDriverException()); this.controlService.doControl(tcsace); Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg)); Assert.assertEquals("CA", tcsace.getReturnCode()); Assert.assertEquals("Y", tcsace.getFatal()); }
From source file:org.cerberus.service.engine.impl.ControlServiceTest.java
License:Open Source License
@Ignore @Test/*from ww w .jav a 2s. c o m*/ public void testDoControlElementPresentWhenWebDriverException() { String property = "id=test"; String value = "null"; String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*"; Identifier identifier = new Identifier(); identifier.setIdentifier("id"); identifier.setLocator("test"); TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution(); tcsace.setControlType("verifyElementPresent"); tcsace.setControlProperty(property); tcsace.setControlValue(value); tcsace.setFatal("Y"); tCExecution.setSession(session); TestCaseStepExecution tcse = new TestCaseStepExecution(); tcse.settCExecution(tCExecution); TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution(); tcsae.setTestCaseStepExecution(tcse); tcsace.setTestCaseStepActionExecution(tcsae); when(webdriverService.isElementPresent(tCExecution.getSession(), identifier)) .thenThrow(new WebDriverException()); this.controlService.doControl(tcsace); Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg)); Assert.assertEquals("CA", tcsace.getReturnCode()); Assert.assertEquals("Y", tcsace.getFatal()); }