package page; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.util.List; import java.lang.reflect.Method; public class HospitalsPage { private WebDriver driver; @FindBy(xpath = "//*[@id=\"searchbyaddress\"]/span") private WebElement searchByAddressButton; @FindBy(xpath = "//*[@id=\"street_search\"]") private WebElement street; @FindBy(xpath = "//*[@id=\"ui-id-8\"]") private List streetChoice; @FindBy(xpath = "//*[@id=\"house_search-button\"]") private WebElement houseButton; @FindBy(xpath = "//*[@id=\"house_search-menu\"]") private List houseNumber; @FindBy(xpath = "//*[@id=\"foundlpu\"]/tbody") private WebElement element; @FindBy(xpath = "//*[@id=\"lpu_search\"]") private WebElement inputHospitalField; @FindBy(css = ".ui-menu-item") private List hospitalsList; @FindBy(xpath = "//*[@id=\"search_go\"]") private WebElement searchHospitalButton; @FindBy(xpath = "//*[@id=\"MainContent\"]/div[1]/div[2]/span/a") private WebElement hospitalViewButton; @FindBy(css = ".l-vis") private List filteredHospitalsList; public HospitalsPage(WebDriver driver) { this.driver = driver; } public String getTitle(){ return driver.getTitle(); } public void searchByAddressButtonClick(){ searchByAddressButton.click(); } public void insertStreet(String str) { street.sendKeys(str); try { Thread.sleep(2000); } catch (Exception e) { e.printStackTrace(); } streetChoice.get(0).click(); } public void chooseHouse() { try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } houseButton.click(); try { Thread.sleep(2000); } catch (Exception e) { e.printStackTrace(); } houseNumber.get(0).click(); } public boolean isHospitalPresent() { try { Thread.sleep(3000); } catch (Exception e) { e.printStackTrace(); } return element.isDisplayed(); } public HospitalsPage setSearchString(String text) { inputHospitalField.sendKeys(text); return this; } public String chooseHospital() { try { Thread.sleep(2000); } catch (Exception e) { e.printStackTrace(); } hospitalsList.get(0).click(); return hospitalsList.get(0).getText(); } public void searchHospitalClick(){ try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } searchHospitalButton.click(); } public void hospitalViewButtonClick(){ hospitalViewButton.click(); } public int getHospitalViewCount(){ String str = hospitalViewButton.getText(); String substr = str.substring(17,18); return Integer.parseInt(substr); } public boolean checkHospitalsFilter(){ if(filteredHospitalsList.size()==getHospitalViewCount()) return true; else return false; } }