/** * Uses the @Step annotation to log the given log message to Allure. * * @param message the message to log to the allure report */ @Step("{message}") public static void logToAllure(String message) { logger.debug("Logged to allure: " + message); }
static String methodNameTemplate(MethodSignature method) { try { Method m = method.getMethod(); String result; if (m.isAnnotationPresent(JDIAction.class)) { return m.getAnnotation(JDIAction.class).value(); } if (m.isAnnotationPresent(Step.class)) { return m.getAnnotation(Step.class).value(); } return null; } catch (Exception ex) { throw new RuntimeException("Surround method issue: " + "Can't get method name template: " + ex.getMessage()); } } private static LogLevels logLevel(JoinPoint joinPoint) {
@Step public void openMainPage() { driver.get("http://ya.ru"); }
@Before("anyMethod() && withStepAnnotation()") public void stepStart(final JoinPoint joinPoint) { final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); final Step step = methodSignature.getMethod().getAnnotation(Step.class); final String uuid = UUID.randomUUID().toString(); final String name = getName(step.value(), methodSignature, joinPoint.getArgs()); final List<Parameter> parameters = getParameters(methodSignature, joinPoint.getArgs()); final StepResult result = new StepResult() .setName(name) .setParameters(parameters); getLifecycle().startStep(uuid, result); }
/** * Open the page in browser */ @Step("Open page") @Override public T open() { webDriver.get(authorUrl + getFullUrl()); return (T) this; }
/** * open the page in browser */ @Step("Open page") public T open() { webDriver.get(getFullUrl()); return (T) this; }
/** * Opens the page in the edit mode * * @return self-reference */ @Step("Open page in editor") public T openInEditor() { webDriver.get(authorUrl + "/editor.html" + getFullUrl()); return (T) this; }
/** * Opens the page in the edit mode * * @return self-reference */ @Step("Open page in editor") public T openInEditor() { webDriver.get(authorUrl + "/editor.html" + getFullUrl()); return (T) this; }
@Override @Step("Provide name {name}") public CreatePageWizard provideName(String name) { createPageProperties.getNameTextField().sendKeys(name); return this; }
/** * Open the page in browser */ @Step("Open page") @Override public T open() { webDriver.get(authorUrl + getFullUrl()); return (T) this; }
@Override @Step("Provide title {title}") public CreatePageWizard provideTitle(String title) { createPageProperties.getTitleTextField().sendKeys(title); return this; }
/** * open the page in browser */ @Step("Open page") public T open() { webDriver.get(getFullUrl()); return (T) this; }
@Override @Step("Logging out of AEM") public void execute() { webDriver.get(authorUrl + "/system/sling/logout.html"); aemAuthCookieFactory.removeCookie(authorUrl); } }
@Override @Step("Select template {templateName}") public CreatePageWizard selectTemplate(String templateName) { templateList.selectTemplate(templateName); getNextButton().click(); return this; }
@Override @Step("Create test page {data.contentPath}") public void execute(SlingPageData data) throws AemPageManipulationException { HttpPost request = new HttpPost(authorIP + data.getContentPath()); request.setEntity(new UrlEncodedFormEntity(data.getContent(), Consts.UTF_8)); try { httpClient.execute(request); } catch (IOException e) { throw new AemPageManipulationException(e); } } }
@Attachment @Step("Make screen shot of results page") public byte[] makeScreenShot() { return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); }
@Override @Step("Submit page for creation") public void submit() { wait.until(input -> getCreateButton().isEnabled()); getCreateButton().click(); List<WebElement> elements = pageCreatedModal.findElements(By.xpath("//coral-button-label[contains(text(),'Done')]")); elements.stream() .findFirst() .orElseThrow(() -> new NoSuchElementException("\"Done\" button not found")) .click(); }
@Override @Step("Logging in to AEM") public void execute() { webDriver.get(authorUrl + "/libs/granite/core/content/login.html"); webDriver.manage() .addCookie(aemAuthCookieFactory.getCookie(authorUrl, authorLoginProperty, authorPassword)); } }
@Step public void search(String text) { driver.findElement(By.id("text")).sendKeys(text); driver.findElement(By.className("suggest2-form__button")).submit(); new WebDriverWait(driver, 10) .withMessage("Could not load results page") .until(mainContainLoaded()); }
@Step("Prepares a test attachment") private SoapAttachment getTestAttachment() { SoapAttachment attachment = mock(SoapAttachment.class); when(attachment.getContent()).thenReturn(IOUtils.toInputStream("Some Content")); when(attachment.getContentType()).thenReturn(MediaType.TEXT); return attachment; }