Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Test instead of @Step for marking steps.
Confusing setup annotations like @BeforeMethod with Allure steps.
✗ Incorrect
The @Step annotation from Allure is used to mark a method as a step in the test report.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
OutputType.BYTES is used to get the screenshot as a byte array for attaching to Allure.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent classes like AllureLogger or WebDriverLogger.
Trying to register the listener on the WebDriver instance.
✗ Incorrect
SelenideLogger.addListener("Allure", new AllureSelenide()); is the correct method to register the AllureSelenide listener.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names in the annotation and method parameter.
Using vague names that do not describe the parameter.
✗ Incorrect
The parameter name 'url' is used both in the step annotation and method parameter for clarity.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like toByteArray or missing the helper method.
Not converting string content to bytes properly.
✗ Incorrect
addAttachment attaches the content; getBytes converts string to bytes; getContentBytes is the helper method name.