0
0
Selenium Javatesting~10 mins

Allure reporting integration in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add an Allure step annotation to the test method.

Selenium Java
@[1]("Open Google homepage")
public void testOpenGoogle() {
    driver.get("https://www.google.com");
}
Drag options to blanks, or click blank then click option'
ATest
BBeforeMethod
CStep
DAfterMethod
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Test instead of @Step for marking steps.
Confusing setup annotations like @BeforeMethod with Allure steps.
2fill in blank
medium

Complete the code to attach a screenshot to the Allure report after test failure.

Selenium Java
public void attachScreenshot() {
    byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs([1].BYTES);
    Allure.addAttachment("Screenshot", new ByteArrayInputStream(screenshot));
}
Drag options to blanks, or click blank then click option'
AInputType
BDataType
CFileType
DOutputType
Attempts:
3 left
💡 Hint
Common Mistakes
Using InputType or FileType which do not exist in this context.
Trying to attach the screenshot without converting to bytes.
3fill in blank
hard

Fix the error in the Allure listener registration code.

Selenium Java
public class TestBase {
    @BeforeClass
    public void setUp() {
        WebDriver driver = new ChromeDriver();
        [1].addListener("Allure", new AllureSelenide());
    }
}
Drag options to blanks, or click blank then click option'
ASelenideLogger
BAllureLogger
CLogger
DWebDriverLogger
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent classes like AllureLogger or WebDriverLogger.
Trying to register the listener on the WebDriver instance.
4fill in blank
hard

Fill both blanks to create an Allure step with a dynamic name and parameter.

Selenium Java
@Step("Open URL: [1]")
public void openPage(String [2]) {
    driver.get([2]);
}
Drag options to blanks, or click blank then click option'
Aurl
Bpage
Clink
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names in the annotation and method parameter.
Using vague names that do not describe the parameter.
5fill in blank
hard

Fill all three blanks to create an Allure attachment method for text logs.

Selenium Java
public void attachTextLog(String name, String content) {
    Allure.[1](name, "text/plain", new ByteArrayInputStream([3](content)), ".txt");
}

private byte[] [3](String content) {
    return content.[2](StandardCharsets.UTF_8);
}
Drag options to blanks, or click blank then click option'
AaddAttachment
BgetBytes
CgetContentBytes
DtoByteArray
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like toByteArray or missing the helper method.
Not converting string content to bytes properly.