Created
December 4, 2024 16:27
-
-
Save borodicht/1207c7bf4f60f0835824aa422fea31ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pages; | |
import io.qameta.allure.Step; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.support.ui.ExpectedConditions; | |
public class HomePage extends BasePage { | |
private final String MENU_OPTION_PATTERN = "//span[text()='%s']//ancestor::one-app-nav-bar-item-root[@role='listitem']"; | |
public HomePage(WebDriver driver) { | |
super(driver); | |
} | |
@Override | |
public HomePage isPageOpened() { | |
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//img[@alt='User']//ancestor::button[@type='button']"))); | |
return this; | |
} | |
@Step("Open Home page") | |
public HomePage open() { | |
driver.get("https://tms9-dev-ed.develop.lightning.force.com/lightning/page/home"); | |
return this; | |
} | |
@Step("Select option {optionName} in the menu bar") | |
public <T extends BasePage> T selectMenuOption(String optionName, Class<T> pageClass) { | |
By setOption = By.xpath(String.format(MENU_OPTION_PATTERN, optionName)); | |
driver.findElement(setOption).click(); | |
try { | |
return pageClass.getDeclaredConstructor(WebDriver.class).newInstance(driver); | |
} catch (Exception e) { | |
throw new RuntimeException(); | |
} | |
} | |
/*и когда вызываешь метод navigate пишешь | |
homePage.selectMenuOption("Account", AccountPage.class); | |
ну и т.д. в зависимости от страницы куда переходишь | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment