извините, я не знаю, правильно ли я создал название. Но у меня проблема в том, что когда я создал объект страницы Tile
и инстанцировал его на тестовой странице, он выдает ошибку сразу после открытия страницы. код ниже:
public class Tile {
private WebDriver driver;
private String title;
private WebElement titleEl;
public Tile(WebDriver driver) {
this.driver = driver;
this.titleEl = driver.findElement(By.xpath("//div[@id='xpathGoesHere']"));
this.title = titleEl.getText();
}
public WebElement getTitleEl() {
return titleEl;
}
public void setTitleEl(WebElement titleEl) {
this.titleEl = titleEl;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
и есть отдельная страница для плиток (как компонент)
public class Tiles {
private WebDriver driver;
public Tiles(WebDriver driver) {
this.driver = driver;
}
другая страница:
public class ThePage extends BasePage {
private final Tile tile;
private final Tiles tiles;
public ThePage(WebDriver driver) {
super(driver);
this.tile = new Tile(driver);
this.tiles = new Tiles(driver);
}
public Tile tile() {
return tile;
}
public Tilesresults() {
return tiles;
}
}
и на тестовой странице:
public class SomeTest extends BaseTest {
private static String URL = "https://www.page.com/home/";
private Tile tile;
private ThePage page;
private String link = "link";
@BeforeMethod
public void setup() {
driver.get(URL);
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
page = new ThePage(driver);
}
@Test
public void test() throws Exception {
// code goes here
tile = new Tile(driver);
tiles.results().getTiles();
tile.getTitle();
}
}
Я пробовал много вещей, и у меня просто больше нет идей, я также проверял страницы POM онлайн, но не мог найти, почему это не работает. Помогите пожалуйста, я новичок в этом PS страница выглядит так:
введите описание изображения здесь