|
1 | 1 | package cucumber; |
2 | 2 |
|
3 | | - |
4 | 3 | import io.cucumber.java.en.*; |
| 4 | +import io.github.bonigarcia.wdm.WebDriverManager; |
5 | 5 | import org.openqa.selenium.*; |
6 | 6 | import org.openqa.selenium.chrome.ChromeDriver; |
7 | 7 | import org.openqa.selenium.support.ui.*; |
8 | 8 | import org.testng.Assert; |
9 | 9 | import java.time.Duration; |
10 | 10 |
|
11 | 11 | public class FreestyleJobSteps { |
| 12 | + |
12 | 13 | private WebDriver driver; |
13 | 14 | private WebElement h1Element; |
14 | 15 |
|
15 | 16 | @Given("I navigate to UMG Gdyni website") |
16 | 17 | public void navigate_to_website() { |
| 18 | + WebDriverManager.chromedriver().setup(); |
17 | 19 | driver = new ChromeDriver(); |
18 | 20 | driver.manage().window().maximize(); |
19 | 21 | driver.get("https://www.umgdy.gov.pl/"); |
20 | 22 | } |
21 | 23 |
|
22 | 24 | @When("I wait for header element to load") |
23 | 25 | public void wait_for_header() { |
24 | | - WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); |
25 | | - h1Element = wait.until(ExpectedConditions.presenceOfElementLocated( |
26 | | - By.xpath("//h1[text()='Urząd Morski w Gdyni']"))); |
| 26 | + WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15)); |
| 27 | + h1Element = wait.until(ExpectedConditions.visibilityOfElementLocated( |
| 28 | + By.xpath("//h1[normalize-space()='Urząd Morski w Gdyni']"))); |
27 | 29 | } |
28 | 30 |
|
29 | 31 | @Then("The header text should be {string}") |
30 | 32 | public void verify_header_text(String expectedText) { |
31 | | - Assert.assertEquals(h1Element.getText(), expectedText); |
| 33 | + Assert.assertEquals( |
| 34 | + h1Element.getText().trim(), |
| 35 | + expectedText, |
| 36 | + "Текст заголовка не соответствует ожидаемому" |
| 37 | + ); |
32 | 38 | driver.quit(); |
33 | 39 | } |
34 | 40 | } |
0 commit comments