Best SeLion code snippet using com.paypal.selion.testcomponents.TestPage.SelionContainer
Source:TestPage.java
...26 private RadioButton xRadioButton;27 private Label logLabel;28 private SelectList xSelectList;29 private Button hiddenButton;30 private SelionContainer selionContainer;31 private Button continueButton;32 private TextField fieldXTextField;33 private CheckBox xCheckBox;34 private Label loadingSpinnerLabel;35 private Button performAnimationButton;36 private static String CLASS_NAME = "TestPage";37 private static String PAGE_DOMAIN = "paypal";38 /**39 * Creates a new TestPage object40 */41 public TestPage() {42 super();43 super.initPage(PAGE_DOMAIN, CLASS_NAME);44 }45 /**46 * Creates a new TestPage object47 *48 * @param siteLocale49 * The Country locale for the site you are accessing50 */51 public TestPage(String siteLocale) {52 super();53 super.initPage(PAGE_DOMAIN, CLASS_NAME, siteLocale);54 }55 public TestPage(String siteLocale, String className) {56 super();57 super.initPage(PAGE_DOMAIN, className, siteLocale);58 }59 public TestPage getPage() {60 return this;61 }62 /**63 * Used to get xRadioButton in the page TestPage64 *65 * @return xRadioButton66 */67 public RadioButton getXRadioButton() {68 RadioButton element = this.xRadioButton;69 if (element == null) {70 this.xRadioButton = new RadioButton(this.getObjectMap().get("xRadioButton"), "xRadioButton", this);71 }72 return this.xRadioButton;73 }74 /**75 * Used to check the control xRadioButton in the page TestPage76 */77 public void checkXRadioButton() {78 getXRadioButton().check();79 }80 /**81 * Used to click the control xRadioButton in the page TestPage82 */83 public void clickXRadioButton() {84 getXRadioButton().click();85 }86 /**87 * Used to get logLabel in the page TestPage88 *89 * @return logLabel90 */91 public Label getLogLabel() {92 Label element = this.logLabel;93 if (element == null) {94 this.logLabel = new Label(this.getObjectMap().get("logLabel"), "logLabel", this);95 }96 return this.logLabel;97 }98 /**99 * Used to check for the specific text available in the control logLabel100 */101 public boolean isTextPresentForLogLabel(String pattern) {102 return getLogLabel().isTextPresent(pattern);103 }104 /**105 * Used to get xSelectList in the page TestPage106 *107 * @return xSelectList108 */109 public SelectList getXSelectList() {110 SelectList element = this.xSelectList;111 if (element == null) {112 this.xSelectList = new SelectList(this.getObjectMap().get("xSelectList"), "xSelectList", this);113 }114 return this.xSelectList;115 }116 /**117 * Used to select element in the control xSelectList based on the value.118 */119 public void selectXSelectListByValue(String value) {120 getXSelectList().selectByValue(value);121 }122 /**123 * Used to select element in the control xSelectList based on the label.124 */125 public void selectXSelectListByLabel(String label) {126 getXSelectList().selectByLabel(label);127 }128 /**129 * Used to select element in the control xSelectList based on the index130 */131 public void selectXSelectListByIndex(int index) {132 getXSelectList().selectByIndex(index);133 }134 /**135 * Used to get hiddenButton in the page TestPage136 *137 * @return hiddenButton138 */139 public Button getHiddenButton() {140 Button element = this.hiddenButton;141 if (element == null) {142 this.hiddenButton = new Button(this.getObjectMap().get("hiddenButton"), "hiddenButton", this);143 }144 return this.hiddenButton;145 }146 /**147 * Used to click hiddenButton in the page TestPage and check that resulting page contains expected item.148 */149 public void clickHiddenButton(Object... expected) {150 getHiddenButton().click(expected);151 }152 /**153 * Used to click hiddenButton in the page TestPage154 */155 public void clickHiddenButton() {156 getHiddenButton().click();157 }158 /**159 * Used to get the value of hiddenButton in the page TestPage.160 *161 * @return text in hiddenButton162 */163 public String getHiddenButtonValue() {164 return getHiddenButton().getText();165 }166 /**167 * Used to get the SelionContainer.168 *169 * @return selionContainer170 */171 public SelionContainer getSelionContainer() {172 SelionContainer element = this.selionContainer;173 if (element == null) {174 this.selionContainer = new SelionContainer(this.getObjectMap().get("selionContainer"),175 "selionContainer", this, this.getObjectContainerMap().get("selionContainer"));176 }177 return this.selionContainer;178 }179 /**180 * Used to get SelionContainer at specified index.181 *182 * @return selionContainer at index183 */184 public SelionContainer getSelionContainer(int index) {185 getSelionContainer().setIndex(index);186 return selionContainer;187 }188 /**189 * Used to get continueButton in the page TestPage190 *191 * @return continueButton192 */193 public Button getContinueButton() {194 Button element = this.continueButton;195 if (element == null) {196 this.continueButton = new Button(this.getObjectMap().get("continueButton"), "continueButton", this);197 }198 return this.continueButton;199 }200 /**201 * Used to click continueButton in the page TestPage and check that resulting page contains expected item.202 */203 public void clickContinueButton(Object... expected) {204 getContinueButton().click(expected);205 }206 /**207 * Used to click continueButton in the page TestPage208 */209 public void clickContinueButton() {210 getContinueButton().click();211 }212 /**213 * Used to get the value of continueButton in the page TestPage.214 *215 * @return text in continueButton216 */217 public String getContinueButtonValue() {218 return getContinueButton().getText();219 }220 /**221 * Used to get fieldXTextField in the page TestPage222 *223 * @return fieldXTextField224 */225 public TextField getFieldXTextField() {226 TextField element = this.fieldXTextField;227 if (element == null) {228 this.fieldXTextField = new TextField(this.getObjectMap().get("fieldXTextField"), "fieldXTextField",229 this);230 }231 return this.fieldXTextField;232 }233 /**234 * Used to set the value of fieldXTextField in the page TestPage.235 */236 public void setFieldXTextFieldValue(String fieldX) {237 getFieldXTextField().type(fieldX);238 }239 /**240 * Used to get the value of fieldXTextField in the page TestPage.241 *242 * @return text in fieldXTextField243 */244 public String getFieldXTextFieldValue() {245 return getFieldXTextField().getText();246 }247 /**248 * Used to get xCheckBox in the page TestPage249 *250 * @return xCheckBox251 */252 public CheckBox getXCheckBox() {253 CheckBox element = this.xCheckBox;254 if (element == null) {255 this.xCheckBox = new CheckBox(this.getObjectMap().get("xCheckBox"), "xCheckBox", this);256 }257 return this.xCheckBox;258 }259 /**260 * Used to check the control xCheckBox in the page TestPage261 */262 public void checkXCheckBox() {263 getXCheckBox().check();264 }265 /**266 * Used to uncheck the control xCheckBox in the page TestPage267 */268 public void uncheckXCheckBox() {269 getXCheckBox().uncheck();270 }271 /**272 * Used to click the control xCheckBox in the page TestPage273 */274 public void clickXCheckBox() {275 getXCheckBox().click();276 }277 /**278 * Used to get loadingSpinnerLabel in the page ThePage279 *280 * @return loadingSpinnerLabel281 */282 public Label getLoadingSpinnerLabel() {283 Label element = this.loadingSpinnerLabel;284 if(element == null) {285 this.loadingSpinnerLabel = new Label(getObjectMap().get("loadingSpinnerLabel"), "loadingSpinnerLabel",286 this);287 }288 return this.loadingSpinnerLabel;289 }290 /**291 * Used to check for the specific text available in the control loadingSpinnerLabel292 */293 public boolean isTextPresentForLoadingSpinnerLabel(String pattern) {294 return getLoadingSpinnerLabel().isTextPresent(pattern);295 }296 /**297 * Used to get performAnimationButton in the page ThePage298 *299 * @return performAnimationButton300 */301 public Button getPerformAnimationButton() {302 Button element = this.performAnimationButton;303 if(element == null) {304 this.performAnimationButton = new Button(getObjectMap().get("performAnimationButton"), "performAnimationButton",305 this);306 }307 return this.performAnimationButton;308 }309 /**310 * Used to click performAnimationButton in the page ThePage and check that resulting page contains expected item.311 */312 public void clickPerformAnimationButton(Object... expected) {313 getPerformAnimationButton().click(expected);314 }315 /**316 * Used to click performAnimationButton in the page ThePage317 */318 public void clickPerformAnimationButton() {319 getPerformAnimationButton().click();320 }321 /**322 * Used to get the value of performAnimationButton in the page ThePage.323 *324 * @return text in performAnimationButton325 */326 public String getPerformAnimationButtonValue() {327 return getPerformAnimationButton().getText();328 }329 public class SelionContainer extends Container {330 private Button containerButton;331 /**332 * SelionContainer Construction method <br>333 * <br>334 * <b>Usage:</b>335 *336 * <pre>337 * private TestPage pageInstance = new TestPage();338 * private TestPage.SelionContainer selionContainer = pageInstance.new SelionContainer("//span[@id='containerLocator']");339 * </pre>340 *341 * @param locator342 * the element locator343 */344 public SelionContainer(String locator) {345 super(locator);346 }347 /**348 * Use this constructor to override default controlName for logging purposes. Default controlName would be the349 * element locator.350 *351 * @param locator352 * the element locator353 * @param controlName354 * the control name used for logging355 */356 public SelionContainer(String locator, String controlName) {357 super(locator, controlName);358 }359 /**360 * Use this constructor to override default controlName and assign a parent361 *362 * @param locator363 * A String that represents the means to locate this element (could be id/name/xpath/css locator).364 * @param controlName365 * the control name used for logging.366 * @param parent367 * A {@link ParentTraits} object that represents the parent element for this element.368 *369 */370 public SelionContainer(String locator, String controlName, ParentTraits parent) {371 super(locator, controlName, parent);372 }373 public SelionContainer(String locator, String controlName, ParentTraits parent,374 java.util.Map<String, String> containerElements) {375 super(locator, controlName, parent, containerElements);376 }377 private SelionContainer getContainer() {378 if (!isInitialized()) {379 getObjectMap();380 }381 return this;382 }383 /**384 *385 * For SelionContainer Button : containerButton386 *387 * Used to get containerButton in selionContainer388 *389 * @return containerButton390 */391 public Button getContainerButton() {392 Button containerElement = getContainer().containerButton;393 if (containerElement == null) {394 getContainer().containerButton = new Button(this.containerElements.get("containerButton"),395 "containerButton", this);396 }397 return getContainer().containerButton;398 }399 }...
Source:BasicPageImplTest.java
...55 String script = getScript();56 driver.executeScript(script);57 Thread.sleep(4000);58 TestPage page = new TestPage("US");59 SeLionAsserts.assertEquals(page.getSelionContainer().getContainerButton().getValue(), "Button 1",60 "Yaml Button from Container at index 0 retrieved succesfully");61 SeLionAsserts.assertEquals(page.getSelionContainer(1).getContainerButton().getValue(), "Button 2",62 "Yaml Button from Container at index 1 retrieved succesfully");63 }64 @Test(groups = { "functional" })65 @WebTest66 public void testPageTitle() throws InterruptedException, IOException {67 Grid.open("about:blank");68 RemoteWebDriver driver = (RemoteWebDriver) Grid.driver().getWrappedDriver();69 String script = getScript();70 driver.executeScript(script);71 Thread.sleep(4000);72 TestPage page = new TestPage("US");73 SeLionAsserts.assertEquals(Grid.driver().getTitle(), page.getExpectedPageTitle(),74 "PageTitle Yaml value retrieved successfully");75 }76 @Test(groups = { "functional" })77 @WebTest78 public void testFallBackLocale() throws InterruptedException, IOException {79 TestPage page = new TestPage("FR");80 SeLionAsserts.assertEquals(page.getFieldXTextField().getLocator(), "//input[@id='fieldXId_FR']",81 "Yaml FR locator returned by SeLion");82 SeLionAsserts.assertEquals(page.getContinueButton().getLocator(), "//input[@id='submit.x']",83 "Yaml US locator returned by SeLion because FR isn't set");84 }85 @Test(groups = { "functional" })86 @WebTest87 public void testPageValidator() throws InterruptedException, IOException {88 Grid.open("about:blank");89 RemoteWebDriver driver = (RemoteWebDriver) Grid.driver().getWrappedDriver();90 String script = getScript();91 driver.executeScript(script);92 Thread.sleep(4000);93 TestPage page = new TestPage("US");94 TestPage pageNotOpened = new TestPage("US", "TestWrongValidatorPage");95 TestPage pageTitleValidation = new TestPage("US", "PageTitleValidationPage");96 SeLionAsserts.assertEquals(page.isCurrentPageInBrowser(), true, "Page is opened in the browser");97 SeLionAsserts.assertEquals(pageNotOpened.isCurrentPageInBrowser(), false, "Page is not opened in the browser");98 // Validate the page by pageTitle, which is the fallback if there are no pageValidators provided.99 SeLionAsserts100 .assertEquals(pageTitleValidation.isCurrentPageInBrowser(), true, "Page is opened in the browser");101 pageTitleValidation.setPageTitle("Incorrect page title");102 SeLionAsserts.assertEquals(pageTitleValidation.isCurrentPageInBrowser(), false,103 "Page is not opened in the browser");104 pageTitleValidation.setPageTitle("* JavaScript");105 SeLionAsserts106 .assertEquals(pageTitleValidation.isCurrentPageInBrowser(), true, "Page is opened in the browser");107 pageTitleValidation.setPageTitle("* title");108 SeLionAsserts.assertEquals(pageTitleValidation.isCurrentPageInBrowser(), false,109 "Page is not opened in the browser");110 }111 @Test(groups = { "functional" })112 @WebTest113 public void testLoadHtmlObjectsWithContainer() {114 TestInitializeElementsPage testInitPage = new TestInitializeElementsPage();115 // Validations to verify valid parent types and elements are resolved as a result of initialization116 SeLionAsserts.assertTrue(testInitPage.getHeaderContainer() != null, "Verify Container is loaded properly");117 SeLionAsserts.assertTrue(118 testInitPage.getPreLoginButton().getParent().getClass().getSuperclass().equals(BasicPageImpl.class),119 "Verify if a page is assigned for element outside container");120 SeLionAsserts.assertTrue(testInitPage.getHeaderContainer().getSomeLink().getParent().getClass()121 .getSuperclass().equals(Container.class),122 "Verify if a Container is assigned for element inside container");123 }124 public class TestPage extends BasicPageImpl {125 private TextField fieldXTextField;126 private Button continueButton;127 private Button hiddenButton;128 private SeLionContainer selionContainer;129 private String CLASS_NAME = "TestPage";130 private String PAGE_DOMAIN = "paypal";131 public TestPage() {132 super.initPage(PAGE_DOMAIN, CLASS_NAME);133 }134 public TestPage(String siteLocale) {135 super.initPage(PAGE_DOMAIN, CLASS_NAME, siteLocale);136 }137 public TestPage(String siteLocale, String className) {138 super.initPage(PAGE_DOMAIN, className, siteLocale);139 }140 public TestPage getPage() {141 if (!isInitialized()) {142 loadObjectMap();143 initializeHtmlObjects(this, this.objectMap);144 }145 return this;146 }147 public Button getContinueButton() {148 return getPage().continueButton;149 }150 public void clickContinueButton(Object... expected) {151 getPage().continueButton.click(expected);152 }153 public void clickContinueButton() {154 getPage().continueButton.click();155 }156 public String getContinueButtonValue() {157 return getPage().continueButton.getText();158 }159 public Button getHiddenButton() {160 return getPage().hiddenButton;161 }162 public void clickHiddenButton(Object... expected) {163 getPage().hiddenButton.click(expected);164 }165 public void clickHiddenButton() {166 getPage().hiddenButton.click();167 }168 public String getHiddenButtonValue() {169 return getPage().hiddenButton.getText();170 }171 public TextField getFieldXTextField() {172 return getPage().fieldXTextField;173 }174 public void setFieldXTextFieldValue(String value) {175 getPage().fieldXTextField.type(value);176 }177 public String getFieldXTextFieldValue() {178 return getPage().fieldXTextField.getText();179 }180 public SeLionContainer getSelionContainer() {181 return getPage().selionContainer;182 }183 public SeLionContainer getSelionContainer(int index) {184 getPage().selionContainer.setIndex(index);185 return selionContainer;186 }187 public class SeLionContainer extends Container {188 private Button containerButton;189 public SeLionContainer(String locator) {190 super(locator);191 }192 public SeLionContainer(String locator, String controlName) {193 super(locator, controlName);194 }195 private SeLionContainer getContainer() {196 if (!isInitialized()) {197 loadObjectMap();...
SelionContainer
Using AI Code Generation
1package com.paypal.selion.testcomponents;2import org.openqa.selenium.By;3import org.openqa.selenium.WebElement;4import com.paypal.selion.platform.grid.Grid;5import com.paypal.selion.platform.html.Button;6import com.paypal.selion.platform.html.CheckBox;7import com.paypal.selion.platform.html.Label;8import com.paypal.selion.platform.html.Link;9import com.paypal.selion.platform.html.ListBox;10import com.paypal.selion.platform.html.RadioButton;11import com.paypal.selion.platform.html.TextField;12import com.paypal.selion.platform.utilities.WebDriverWaitUtils;13public class TestPage {14 public static class SelionContainer {15 private By by;16 public SelionContainer(By by) {17 this.by = by;18 }19 public SelionContainer(String id) {20 this(By.id(id));21 }22 public SelionContainer(WebElement element) {23 }24 public Button getButton(String id) {25 return new Button(Grid.driver(), by, id);26 }27 public CheckBox getCheckBox(String id) {28 return new CheckBox(Grid.driver(), by, id);29 }30 public Label getLabel(String id) {31 return new Label(Grid.driver(), by, id);32 }33 public Link getLink(String id) {34 return new Link(Grid.driver(), by, id);35 }36 public ListBox getListBox(String id) {37 return new ListBox(Grid.driver(), by, id);38 }39 public RadioButton getRadioButton(String id) {40 return new RadioButton(Grid.driver(), by, id);41 }42 public TextField getTextField(String id) {43 return new TextField(Grid.driver(), by, id);44 }45 public void waitForElementPresent() {46 WebDriverWaitUtils.waitUntilElementIsPresent(by);47 }48 }49 public static SelionContainer getSelionContainer(String id) {50 return new SelionContainer(id);51 }52 public static SelionContainer getSelionContainer(By by) {53 return new SelionContainer(by);54 }55 public static SelionContainer getSelionContainer(WebElement element) {56 return new SelionContainer(element);57 }58}59package com.paypal.selion.testcomponents;60import org.openqa.selenium.By;61import org.openqa.selenium.WebElement;62import org.testng.annotations.Test;63import com.paypal.selion
SelionContainer
Using AI Code Generation
1package com.paypal.selion.testcomponents;2import org.openqa.selenium.WebElement;3import org.openqa.selenium.support.FindBy;4import com.paypal.selion.platform.grid.Grid;5import com.paypal.selion.platform.html.Label;6import com.paypal.selion.platform.html.TextField;7import com.paypal.selion.platform.utilities.WebDriverWaitUtils;8public class TestPage extends AbstractPage {9 @FindBy(id = "name")10 private WebElement name;11 public TestPage() {12 Grid.driver().manage().window().maximize();13 WebDriverWaitUtils.waitUntilElementIsVisible(name);14 }15 public TextField getName() {16 return new TextField(name);17 }18 public Label getLabel() {19 return new Label(name);20 }21 public static void main(String[] args) {22 TestPage page = new TestPage();23 page.getName().type("Selion");24 System.out.println(page.getLabel().getText());25 }26}27package com.paypal.selion.testcomponents;28import org.openqa.selenium.WebElement;29import org.openqa.selenium.support.FindBy;30import com.paypal.selion.platform.grid.Grid;31import com.paypal.selion.platform.html.Label;32import com.paypal.selion.platform.html.TextField;33import com.paypal.selion.platform.utilities.WebDriverWaitUtils;34public class TestPage extends AbstractPage {35 @FindBy(id = "name")36 private WebElement name;37 public TestPage() {38 Grid.driver().manage().window().maximize();39 WebDriverWaitUtils.waitUntilElementIsVisible(name);40 }41 public TextField getName() {42 return new TextField(name);43 }44 public Label getLabel() {45 return new Label(name);46 }47 public static void main(String[] args) {48 TestPage page = new TestPage();49 page.getName().type("Selion");50 System.out.println(page.getLabel().getText());51 }52}53package com.paypal.selion.testcomponents;54import org.openqa.selenium.WebElement;55import org.openqa.selenium.support.FindBy;56import com.paypal.selion.platform.grid.Grid;57import com.paypal.selion.platform.html.Label;58import com.paypal.selion.platform.html.TextField
SelionContainer
Using AI Code Generation
1import com.paypal.selion.testcomponents.TestPage;2public class TestPageTest {3 public static void main(String[] args) {4 TestPage page = SelionContainer.get(TestPage.class);5 page.clickButton();6 }7}8import com.paypal.selion.testcomponents.TestPage;9public class TestPageTest {10 public static void main(String[] args) {11 TestPage page = SelionContainer.get(TestPage.class);12 page.clickButton();13 }14}15import com.paypal.selion.testcomponents.TestPage;16public class TestPageTest {17 public static void main(String[] args) {18 TestPage page = SelionContainer.get(TestPage.class);19 page.clickButton();20 }21}22import com.paypal.selion.testcomponents.TestPage;23public class TestPageTest {24 public static void main(String[] args) {25 TestPage page = SelionContainer.get(TestPage.class);26 page.clickButton();27 }28}29import com.paypal.selion.testcomponents.TestPage;30public class TestPageTest {31 public static void main(String[] args) {32 TestPage page = SelionContainer.get(TestPage.class);33 page.clickButton();34 }35}36import com.paypal.selion.testcomponents.TestPage;37public class TestPageTest {38 public static void main(String[] args) {39 TestPage page = SelionContainer.get(TestPage.class);40 page.clickButton();41 }42}
SelionContainer
Using AI Code Generation
1public void testSelionContainer() {2 TestPage testPage = SelionContainer.get(TestPage.class);3 TestPage testPage1 = SelionContainer.get(TestPage.class);4 Assert.assertTrue(testPage == testPage1);5}6public void testSelionContainer() {7 TestPage testPage = SelionContainer.get(TestPage.class);8 TestPage testPage1 = SelionContainer.get(TestPage.class);9 Assert.assertTrue(testPage == testPage1);10}11public void testSelionContainer() {12 TestPage testPage = SelionContainer.get(TestPage.class);13 TestPage testPage1 = SelionContainer.get(TestPage.class);14 Assert.assertTrue(testPage == testPage1);15}16public void testSelionContainer() {17 TestPage testPage = SelionContainer.get(TestPage.class);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!