forked from saucelabs-training/demo-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJUnit5W3CChromeTest.java
42 lines (38 loc) · 1.45 KB
/
JUnit5W3CChromeTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.saucedemo;
import com.saucelabs.saucebindings.SauceOptions;
import com.saucelabs.saucebindings.SauceSession;
import org.junit.jupiter.api.*;
import org.openqa.selenium.WebDriver;
public class JUnit5W3CChromeTest {
protected WebDriver driver;
public Boolean result = false;
private SauceSession sauceSession;
@BeforeEach
public void setup(TestInfo testInfo) {
SauceOptions sauceOptions = new SauceOptions();
sauceOptions.setName(testInfo.getDisplayName());
sauceSession = new SauceSession(sauceOptions);
driver = sauceSession.start();
}
/**
* @Tag is a JUnit 5 annotation that defines test method tags that aid in reporting and filtering tests.
* For more information visit the docs: https://junit.org/junit5/docs/5.0.2/api/org/junit/jupiter/api/Tag.html
*/
@Tag("w3c-chrome-tests")
/**
* @DisplayName is a JUnit 5 annotation that defines test case name.
* For more information visit the docs: https://junit.org/junit5/docs/5.0.2/api/org/junit/jupiter/api/DisplayName.html
*/
@DisplayName("Junit5W3CChromeTest")
@Test
public void JUnit5w3cChromeTest() throws AssertionError {
driver.navigate().to("https://www.saucedemo.com");
String getTitle = driver.getTitle();
Assertions.assertEquals(getTitle, "Swag Labs");
result = true;
}
@AfterEach
public void teardown() {
sauceSession.stop(result);
}
}