Implement BasePage with functionality common to all pages
This commit is contained in:
parent
9ef157f877
commit
b4904adfb4
|
|
@ -0,0 +1,25 @@
|
||||||
|
package pages;
|
||||||
|
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
|
public abstract class BasePage
|
||||||
|
{
|
||||||
|
protected WebDriver driver = null;
|
||||||
|
|
||||||
|
protected BasePage(WebDriver driver)
|
||||||
|
{
|
||||||
|
this.driver = driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sleep(long millis)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(millis);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,7 +10,9 @@ import org.openqa.selenium.support.PageFactory;
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
public class WaitingStrategiesPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class WaitingStrategiesPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Waiting Strategies')]")
|
@FindBy(xpath = "//button[contains(text(),'Waiting Strategies')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -33,11 +35,9 @@ public class WaitingStrategiesPage
|
||||||
@FindBy(id = "dynamic-input")
|
@FindBy(id = "dynamic-input")
|
||||||
private WebElement dynamicInput;
|
private WebElement dynamicInput;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public WaitingStrategiesPage(WebDriver driver)
|
public WaitingStrategiesPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,15 @@ package pages.webelements;
|
||||||
import org.openqa.selenium.Alert;
|
import org.openqa.selenium.Alert;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
public class AlertPanel
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class AlertPanel extends BasePage
|
||||||
{
|
{
|
||||||
private Alert alert = null;
|
private Alert alert = null;
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public AlertPanel(WebDriver driver)
|
public AlertPanel(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
alert = driver.switchTo().alert();
|
alert = driver.switchTo().alert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class CheckboxesAndRadioButtonsPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class CheckboxesAndRadioButtonsPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Checkboxes and Radio Buttons')]")
|
@FindBy(xpath = "//button[contains(text(),'Checkboxes and Radio Buttons')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -20,11 +22,9 @@ public class CheckboxesAndRadioButtonsPage
|
||||||
@FindBy(xpath = "//div[@id='radiobuttons']//input")
|
@FindBy(xpath = "//div[@id='radiobuttons']//input")
|
||||||
private List<WebElement> radioButtons;
|
private List<WebElement> radioButtons;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public CheckboxesAndRadioButtonsPage(WebDriver driver)
|
public CheckboxesAndRadioButtonsPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,15 @@ package pages.webelements;
|
||||||
import org.openqa.selenium.Alert;
|
import org.openqa.selenium.Alert;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
public class ConfirmPanel
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class ConfirmPanel extends BasePage
|
||||||
{
|
{
|
||||||
private Alert confirm = null;
|
private Alert confirm = null;
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public ConfirmPanel(WebDriver driver)
|
public ConfirmPanel(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
confirm = driver.switchTo().alert();
|
confirm = driver.switchTo().alert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class DatePickersPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class DatePickersPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Date Pickers')]")
|
@FindBy(xpath = "//button[contains(text(),'Date Pickers')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -18,11 +20,9 @@ public class DatePickersPage
|
||||||
@FindBy(id = "html-datepicker")
|
@FindBy(id = "html-datepicker")
|
||||||
private WebElement htmlDatePicker;
|
private WebElement htmlDatePicker;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public DatePickersPage(WebDriver driver)
|
public DatePickersPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +45,8 @@ public class DatePickersPage
|
||||||
|
|
||||||
SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
inputDateAsStringInJavaScriptFormat = outputDateFormat.format(inputDate);
|
inputDateAsStringInJavaScriptFormat = outputDateFormat.format(inputDate);
|
||||||
} catch (ParseException e)
|
}
|
||||||
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class FramesAndWindowsPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class FramesAndWindowsPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Frames and Windows')]")
|
@FindBy(xpath = "//button[contains(text(),'Frames and Windows')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -16,11 +18,9 @@ public class FramesAndWindowsPage
|
||||||
@FindBy(id = "new-window-button")
|
@FindBy(id = "new-window-button")
|
||||||
private WebElement newWindowButton;
|
private WebElement newWindowButton;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public FramesAndWindowsPage(WebDriver driver)
|
public FramesAndWindowsPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ import org.openqa.selenium.interactions.Actions;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class InputRangePage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class InputRangePage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Input Range')]")
|
@FindBy(xpath = "//button[contains(text(),'Input Range')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -15,11 +17,9 @@ public class InputRangePage
|
||||||
@FindBy(id = "range-input")
|
@FindBy(id = "range-input")
|
||||||
private WebElement rangeInput;
|
private WebElement rangeInput;
|
||||||
|
|
||||||
private WebDriver driver;
|
|
||||||
|
|
||||||
public InputRangePage(WebDriver driver)
|
public InputRangePage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class InputsWithUIDialogsPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class InputsWithUIDialogsPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Inputs With UI Dialogs')]")
|
@FindBy(xpath = "//button[contains(text(),'Inputs With UI Dialogs')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -17,11 +19,9 @@ public class InputsWithUIDialogsPage
|
||||||
@FindBy(id = "file-input")
|
@FindBy(id = "file-input")
|
||||||
private WebElement fileInput;
|
private WebElement fileInput;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public InputsWithUIDialogsPage(WebDriver driver)
|
public InputsWithUIDialogsPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class JavaScriptPopupMessagesPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class JavaScriptPopupMessagesPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'JavaScript Popup Messages')]")
|
@FindBy(xpath = "//button[contains(text(),'JavaScript Popup Messages')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -19,11 +21,9 @@ public class JavaScriptPopupMessagesPage
|
||||||
@FindBy(id = "prompt-button")
|
@FindBy(id = "prompt-button")
|
||||||
private WebElement promptButton;
|
private WebElement promptButton;
|
||||||
|
|
||||||
private WebDriver driver;
|
|
||||||
|
|
||||||
public JavaScriptPopupMessagesPage(WebDriver driver)
|
public JavaScriptPopupMessagesPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,16 @@ import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.How;
|
import org.openqa.selenium.support.How;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class ModalDialogPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class ModalDialogPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(how = How.ID, using = "form-interactions-modal-close-button")
|
@FindBy(how = How.ID, using = "form-interactions-modal-close-button")
|
||||||
private WebElement closeButton;
|
private WebElement closeButton;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public ModalDialogPage(WebDriver driver)
|
public ModalDialogPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class MostCommonInputsPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class MostCommonInputsPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Most Common Inputs')]")
|
@FindBy(xpath = "//button[contains(text(),'Most Common Inputs')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -31,11 +33,9 @@ public class MostCommonInputsPage
|
||||||
@FindBy(id = "form-interactions-submit-button")
|
@FindBy(id = "form-interactions-submit-button")
|
||||||
private WebElement submitButton;
|
private WebElement submitButton;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public MostCommonInputsPage(WebDriver driver)
|
public MostCommonInputsPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,16 +83,4 @@ public class MostCommonInputsPage
|
||||||
{
|
{
|
||||||
return readonlyInput.getAttribute("value");
|
return readonlyInput.getAttribute("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sleep(long millis)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(millis);
|
|
||||||
} catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,26 +4,15 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
public class NewWindow
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class NewWindow extends BasePage
|
||||||
{
|
{
|
||||||
private static void sleep(long milliseconds)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(milliseconds);
|
|
||||||
} catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String originalWindowHandle;
|
private String originalWindowHandle;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public NewWindow(WebDriver driver)
|
public NewWindow(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
|
|
||||||
// Get the handle (or identifier) of the original window:
|
// Get the handle (or identifier) of the original window:
|
||||||
originalWindowHandle = driver.getWindowHandle();
|
originalWindowHandle = driver.getWindowHandle();
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,15 @@ package pages.webelements;
|
||||||
import org.openqa.selenium.Alert;
|
import org.openqa.selenium.Alert;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
public class PromptPanel
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class PromptPanel extends BasePage
|
||||||
{
|
{
|
||||||
private Alert prompt = null;
|
private Alert prompt = null;
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public PromptPanel(WebDriver driver)
|
public PromptPanel(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
prompt = driver.switchTo().alert();
|
prompt = driver.switchTo().alert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
import org.openqa.selenium.support.ui.Select;
|
import org.openqa.selenium.support.ui.Select;
|
||||||
|
|
||||||
public class SelectDatalistAndOptionsPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class SelectDatalistAndOptionsPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Select, Datalist and Options')]")
|
@FindBy(xpath = "//button[contains(text(),'Select, Datalist and Options')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -24,11 +26,9 @@ public class SelectDatalistAndOptionsPage
|
||||||
Select select = null;
|
Select select = null;
|
||||||
List<WebElement> selectOptions = null;
|
List<WebElement> selectOptions = null;
|
||||||
|
|
||||||
private WebDriver driver;
|
|
||||||
|
|
||||||
public SelectDatalistAndOptionsPage(WebDriver driver)
|
public SelectDatalistAndOptionsPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
|
|
||||||
select = new Select(selectElement);
|
select = new Select(selectElement);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
public class TablesPage
|
import pages.BasePage;
|
||||||
|
|
||||||
|
public class TablesPage extends BasePage
|
||||||
{
|
{
|
||||||
@FindBy(xpath = "//button[contains(text(),'Tables')]")
|
@FindBy(xpath = "//button[contains(text(),'Tables')]")
|
||||||
private WebElement accordionItem;
|
private WebElement accordionItem;
|
||||||
|
|
@ -19,11 +21,9 @@ public class TablesPage
|
||||||
|
|
||||||
List<WebElement> headerRow;
|
List<WebElement> headerRow;
|
||||||
|
|
||||||
private WebDriver driver = null;
|
|
||||||
|
|
||||||
public TablesPage(WebDriver driver)
|
public TablesPage(WebDriver driver)
|
||||||
{
|
{
|
||||||
this.driver = driver;
|
super(driver);
|
||||||
PageFactory.initElements(this.driver, this);
|
PageFactory.initElements(this.driver, this);
|
||||||
|
|
||||||
// Take the cells of the 1st row (header row):
|
// Take the cells of the 1st row (header row):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue