com.frameworkium.core.ui.UITestLifecycle Java Examples
The following examples show how to use
com.frameworkium.core.ui.UITestLifecycle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UITestRunner.java From frameworkium-bdd with Apache License 2.0 | 5 votes |
@BeforeMethod(alwaysRun = true) public void setTestName(Method method, Object[] testData) { PickleEvent pickleEvent = ((PickleEventWrapper) testData[0]).getPickleEvent(); String scenarioName = pickleEvent.pickle.getName(); this.scenarioName.set(scenarioName); logger.info("START {}", scenarioName); UITestLifecycle.get().beforeTestMethod(scenarioName); }
Example #2
Source File: CaptureListener.java From frameworkium-core with Apache License 2.0 | 5 votes |
private void takeScreenshotAndSend(String action, WebDriver driver, Throwable thrw) { UITestLifecycle.get().getCapture().takeAndSendScreenshotWithError( new Command(action, "n/a", "n/a"), driver, thrw.getMessage() + "\n" + ExceptionUtils.getStackTrace(thrw)); }
Example #3
Source File: CaptureListener.java From frameworkium-core with Apache License 2.0 | 5 votes |
private void sendFinalScreenshot(ITestResult result, String action) { if (ScreenshotCapture.isRequired() && isUITest()) { Throwable thrw = result.getThrowable(); WebDriver driver = UITestLifecycle.get().getWebDriver(); if (null != thrw) { takeScreenshotAndSend(action, driver, thrw); } else { Command command = new Command(action, "n/a", "n/a"); takeScreenshotAndSend(command, driver); } } }
Example #4
Source File: ScreenshotCapture.java From frameworkium-core with Apache License 2.0 | 5 votes |
private String getTestSessionURL() throws MalformedURLException { URL gridURL = new URL(Property.GRID_URL.getValue()); return String.format( "%s://%s:%d/grid/api/testsession?session=%s", gridURL.getProtocol(), gridURL.getHost(), gridURL.getPort(), UITestLifecycle.get().getRemoteSessionId()); }
Example #5
Source File: Browser.java From frameworkium-core with Apache License 2.0 | 5 votes |
/** * Create browser object. */ public Browser() { Optional<String> userAgent = UITestLifecycle.get().getUserAgent(); if (userAgent.isPresent() && !userAgent.get().isEmpty()) { UserAgentStringParser uaParser = UADetectorServiceFactory.getResourceModuleParser(); ReadableUserAgent agent = uaParser.parse(userAgent.get()); this.name = agent.getName(); this.version = agent.getVersionNumber().toVersionString(); this.device = agent.getDeviceCategory().getName(); this.platform = agent.getOperatingSystem().getName(); this.platformVersion = agent.getOperatingSystem().getVersionNumber().toVersionString(); } else { // Fall-back to the Property class if (BROWSER.isSpecified()) { this.name = BROWSER.getValue().toLowerCase(); } else { this.name = DriverSetup.DEFAULT_BROWSER.toString(); } if (BROWSER_VERSION.isSpecified()) { this.version = BROWSER_VERSION.getValue(); } if (DEVICE.isSpecified()) { this.device = DEVICE.getValue(); } if (PLATFORM.isSpecified()) { this.platform = PLATFORM.getValue(); } if (PLATFORM_VERSION.isSpecified()) { this.platformVersion = PLATFORM_VERSION.getValue(); } } }
Example #6
Source File: BasePage.java From frameworkium-core with Apache License 2.0 | 5 votes |
private void takePageLoadedScreenshotAndSendToCapture() { if (ScreenshotCapture.isRequired()) { Command pageLoadCommand = new Command( "load", "page", getSimplePageObjectName()); UITestLifecycle.get().getCapture().takeAndSendScreenshot( pageLoadCommand, driver); } }
Example #7
Source File: VideoListener.java From frameworkium-core with Apache License 2.0 | 5 votes |
@Override public void onTestStart(ITestResult iTestResult) { if (VideoCapture.isRequired()) { VideoCapture.saveTestSessionID( iTestResult.getName(), UITestLifecycle.get().getRemoteSessionId()); } }
Example #8
Source File: ResultLoggerListener.java From frameworkium-core with Apache License 2.0 | 5 votes |
private String baseComment(ITestResult result) { StringBuilder commentBuilder = new StringBuilder(); commentBuilder.append("Test: ") .append(result.getTestClass().getName()) .append(".") .append(result.getMethod().getMethodName()) .append("\nDuration: ") .append(((result.getEndMillis() - result.getStartMillis()) / MILLIS_PER_SECOND)) .append("seconds"); if (!isNull(System.getenv("BUILD_URL"))) { commentBuilder.append("Jenkins build: ") .append(System.getenv("BUILD_URL")); } if (ScreenshotCapture.isRequired()) { commentBuilder.append("Capture API: ") .append(CAPTURE_URL.getValue()); } commentBuilder.append("\nOS: ") .append(getOSInfo()) .append("\nUserAgent: ") .append(UITestLifecycle.get().getUserAgent()); if (!isNull(result.getThrowable())) { commentBuilder.append("\nStacktrace: ") .append(Throwables.getStackTraceAsString(result.getThrowable())); } return commentBuilder.toString(); }
Example #9
Source File: CaptureListener.java From frameworkium-core with Apache License 2.0 | 4 votes |
private boolean isUITest() { return UITestLifecycle.get().isInitialised(); }
Example #10
Source File: AllureProperties.java From frameworkium-core with Apache License 2.0 | 4 votes |
private static Properties getUIProperties() { Properties props = new Properties(); UITestLifecycle.get().getUserAgent() .ifPresent(ua -> props.setProperty("UserAgent", ua)); return props; }
Example #11
Source File: UITestRunner.java From frameworkium-bdd with Apache License 2.0 | 4 votes |
@BeforeClass(alwaysRun = true) public void setUpClass() { testNGCucumberRunner = new TestNGCucumberRunner(this.getClass()); // This is the only UI Test Class so no need for separate @BeforeSuite UITestLifecycle.get().beforeSuite(); }
Example #12
Source File: FrameworkiumBugsTest.java From frameworkium-core with Apache License 2.0 | 4 votes |
@BeforeMethod(dependsOnMethods = "configureBrowserBeforeTest") public void configureBrowserBeforeUse_allows_browser_access_in_before_method() { assertThat(UITestLifecycle.get().getWebDriver().getPageSource()).isNotEmpty(); }
Example #13
Source File: CaptureListener.java From frameworkium-core with Apache License 2.0 | 4 votes |
private void takeScreenshotAndSend(Command command, WebDriver driver) { UITestLifecycle.get().getCapture().takeAndSendScreenshot(command, driver); }
Example #14
Source File: ScreenshotListener.java From frameworkium-core with Apache License 2.0 | 4 votes |
private void takeScreenshotAndSaveLocally(String testName) { takeScreenshotAndSaveLocally( testName, (TakesScreenshot) UITestLifecycle.get().getWebDriver()); }
Example #15
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
@Override public String getSessionId() { return UITestLifecycle.get().getRemoteSessionId(); }
Example #16
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
/** @deprecated use {@code UITestLifecycle.get().getRemoteSessionId()}. */ @Deprecated public static String getThreadSessionId() { return UITestLifecycle.get().getRemoteSessionId(); }
Example #17
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
/** * @return the user agent of the browser in the first UI test to run. * @deprecated use {@code UITestLifecycle.get().getUserAgent()}. */ @Deprecated public static Optional<String> getUserAgent() { return UITestLifecycle.get().getUserAgent(); }
Example #18
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
/** * @deprecated use {@code UITestLifecycle.get().getWait()}. */ @Deprecated public static Wait<WebDriver> getWait() { return UITestLifecycle.get().getWait(); }
Example #19
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
/** * @deprecated use {@code UITestLifecycle.get().getCapture()}. */ @Deprecated public static ScreenshotCapture getCapture() { return UITestLifecycle.get().getCapture(); }
Example #20
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
/** * @return the {@link WebDriver} used by the current thread. * @deprecated use {@code UITestLifecycle.get().getWebDriver()}. */ @Deprecated public static WebDriver getWebDriver() { return UITestLifecycle.get().getWebDriver(); }
Example #21
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
/** Tears down the browser after the test method. */ @AfterMethod(alwaysRun = true) protected static void tearDownDriver() { UITestLifecycle.get().afterTestMethod(); }
Example #22
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 4 votes |
/** * Runs before the test suite to initialise a pool of drivers, if requested. */ @BeforeSuite(alwaysRun = true) protected static void initialiseDriverPool() { UITestLifecycle.get().beforeSuite(); }
Example #23
Source File: BasePage.java From frameworkium-core with Apache License 2.0 | 4 votes |
private void updatePageTimeout(Duration timeout) { wait = UITestLifecycle.get().newWaitWithTimeout(timeout); JavascriptExecutor jsExecutor = (JavascriptExecutor) driver; visibility = new Visibility(wait, jsExecutor); javascriptWait = new JavascriptWait(jsExecutor, wait); }
Example #24
Source File: BasePage.java From frameworkium-core with Apache License 2.0 | 4 votes |
public BasePage() { this(UITestLifecycle.get().getWebDriver(), UITestLifecycle.get().getWait()); }
Example #25
Source File: HomePage.java From frameworkium-examples with Apache License 2.0 | 4 votes |
@Step("Open home page") public static HomePage open() { UITestLifecycle.get().getWebDriver().manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); return PageFactory.newInstance(HomePage.class, "https://angularjs.org/"); }
Example #26
Source File: UITestRunner.java From frameworkium-bdd with Apache License 2.0 | 4 votes |
@AfterClass(alwaysRun = true) public void tearDownClass() { testNGCucumberRunner.finish(); UITestLifecycle.get().afterTestSuite(); }
Example #27
Source File: UITestRunner.java From frameworkium-bdd with Apache License 2.0 | 4 votes |
@AfterMethod public void afterMethod(ITestResult result) { UITestLifecycle.get().afterTestMethod(); logResult(result); }
Example #28
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 2 votes |
/** * Create a new {@link Wait} with timeout. * * @param timeout timeout {@link Duration} for the {@link Wait} * @return a new {@link Wait} for the thread local driver and given timeout * which also ignores {@link NoSuchElementException} and * {@link StaleElementReferenceException} * @deprecated use {@code UITestLifecycle.get().newWaitWithTimeout(Duration)}. */ @Deprecated public static Wait<WebDriver> newWaitWithTimeout(Duration timeout) { return UITestLifecycle.get().newWaitWithTimeout(timeout); }
Example #29
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 2 votes |
/** * Create a new {@link Wait} with ThreadLocal driver and default timeout. * * @deprecated use {@code UITestLifecycle.get().getWait()}. */ @Deprecated public static Wait<WebDriver> newDefaultWait() { return UITestLifecycle.get().newDefaultWait(); }
Example #30
Source File: BaseUITest.java From frameworkium-core with Apache License 2.0 | 2 votes |
/** * <ul> * <li>Ensures each driver in the pool has {@code quit()} * <li>Processes remaining screenshot backlog * <li>Create Allure properties * </ul> */ @AfterSuite(alwaysRun = true) protected static void afterTestSuiteCleanUp() { UITestLifecycle.get().afterTestSuite(); }