Skip to content

Commit

Permalink
added new scenario in Contents.feature
Browse files Browse the repository at this point in the history
  • Loading branch information
irinaBerendeeva87 committed Mar 18, 2024
1 parent 5badce4 commit c185f1a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.15.0</version>
<version>4.18.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.15.0</version>
<version>4.18.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-devtools-v119 -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-devtools-v119</artifactId>
<version>4.15.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.seleniumhq.selenium</groupId>-->
<!-- <artifactId>selenium-devtools-v119</artifactId>-->
<!-- <version>4.15.0</version>-->
<!-- </dependency>-->


<dependency>
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/pageobject/MainPageObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public class MainPageObject extends BasePageObject {
@FindBy(xpath = "//span[text()='Preferences']")
protected WebElement preferencesElement;

@FindBy(id = "vector-main-menu-dropdown")
protected WebElement dropdownMenu;

@FindBy(id="n-contents")
protected WebElement contentsDropdownEl;

@FindBy(id="firstHeading")
protected WebElement contentsPageTitle;

public MainPageObject(DriverHolder driverHolder) {
super(driverHolder.getDriver());
}
Expand Down Expand Up @@ -74,6 +83,18 @@ public void openPreferences(){
clickUserLinkDropdown();
preferencesElement.click();
// sleep(1000);
}

public void clickDropdownMenu(){
waitForVisibility(dropdownMenu).click();
}

public void clickContents(){
waitForVisibility(contentsDropdownEl).click();
}

public String getContentPageTitle(){
waitForVisibility(contentsPageTitle);
return contentsPageTitle.getText();
}
}
14 changes: 14 additions & 0 deletions src/test/java/steps/MainPageStepDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,18 @@ public void userShouldLogOut() {
public void theUserOpensTheAccountPreference() {
mainPageObject.openPreferences();
}

@When("the user clicks on dropdown menu")
public void the_user_clicks_on_dropdown_menu() {
mainPageObject.clickDropdownMenu();
}
@When("clicks the Contents")
public void clicks_the_contents() {
mainPageObject.clickContents();
}
@Then("the user should be on the Wikipedia:Contents")
public void the_user_should_be_on_the_wikipedia_contents() {
String contentsTitleText = mainPageObject.getContentPageTitle();
assertTrue("The page doesn't have a title",contentsTitleText.contains("Contents"));
}
}
7 changes: 7 additions & 0 deletions src/test/resources/features/Contents.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Navigate to Contents page

Scenario: User can navigate to Contents page via dropdown menu
Given the user is on the Wikipedia homepage
When the user clicks on dropdown menu
And clicks the Contents
Then the user should be on the Wikipedia:Contents

0 comments on commit c185f1a

Please sign in to comment.