How to use AbstractContainer method of com.paypal.selion.platform.html.AbstractContainer class

Best SeLion code snippet using com.paypal.selion.platform.html.AbstractContainer.AbstractContainer

Source:AbstractContainer.java Github

copy

Full Screen

...34 * <tr>35 * <td><b><i> A stand alone container</b></i>36 * 37 * <pre>38 * class MyContainer extends AbstractContainer {39 * 40 * public MyContainer(String locator) {41 * super(locator);42 * }43 * 44 * public MyContainer(String locator, String controlName) {45 * super(locator, controlName);46 * }47 * 48 * private TextField myTextField = new TextField(this, &quot;id=nameTextField&quot;);49 * 50 * public TextField getMyTextField() {51 * return myTextField;52 * }53 * }54 * </pre>55 * 56 * </td>57 * <td>58 * 59 * <pre>60 * MyContainer sampleContainer = new MyContainer("id=sampleLocator");61 * 62 * <u>Locate an element at index 0 inside the container</u>63 * 64 * sampleContainer.locateElement(0, "A locator to be searched in a container") ;65 * 66 * <u>To Retrieve the no. of containers</u> 67 * 68 * sampleContainer.size();69 * 70 * <u>To perform an operation with an element inside the container</u>71 * 72 * sampleContainer.getMyTextField().type("Hi! Welcome");73 * 74 * <b><h2>Note:</b> A stand alone constructor does not have a parent by default.75 * Hence access to method getCurrentPage() will resolve to null.76 * </pre>77 * 78 * </td>79 * </tr>80 * <tr>81 * <td>82 * <b><i>A container inside a page</i></b>83 * 84 * <pre>85 * public class MyPage extends BasePageImpl {86 * private MyContainer myContainer;87 * 88 * public MyPage() {89 * super.initPage(PAGE_DOMAIN, CLASS_NAME);90 * }91 * 92 * public MyPage(String siteLocale) {93 * super.initPage(PAGE_DOMAIN, CLASS_NAME, siteLocale);94 * }95 * 96 * public MyPage getPage() {97 * if (!isInitialized()) {98 * loadObjectMap();99 * initializeHtmlObjects(this, this.objectMap);100 * }101 * return this;102 * }103 * 104 * public MyContainer getMyContainer() {105 * return getPage().myContainer;106 * }107 * 108 * public MyContainer getMyContainer(int index) {109 * getPage().myContainer.setIndex(index);110 * return myContainer;111 * }112 * 113 * <b> Container creation </b>114 * class MyContainer extends AbstractContainer {115 * public MyContainer(String locator) {116 * super(locator);117 * }118 * 119 * public MyContainer(String locator, String controlName) {120 * super(locator, controlName);121 * }122 * 123 * private TextField myTextField;124 * 125 * public TextField getMyTextField() {126 * return myTextField;127 * }128 * }129 * }130 * </pre>131 * 132 * </td>133 * <td>134 * 135 * <pre>136 * <u>To retrieve a child element from a container at a specified index:</u>137 * 138 * <pre>139 * MyPage myPage = new MyPage();140 * myPage.getMyContainer(1).getMyTextField();141 * </pre>142 * 143 * <u>To retrieve a child element from a container at the last specified index or 0 if no index has ever been144 * specified:</u>145 * 146 * <pre>147 * MyPage myPage = new MyPage();148 * myPage.getMyContainer().getMyTextField();149 * </pre>150 * 151 * <u>To retrieve the number of containers found on the page:</u>152 * 153 * <pre>154 * MyPage myPage = new MyPage();155 * myPage.getMyContainer().size();156 * 157 * <h2><b>Note:</b> In this use case, access to getCurrentPage will resolve to the page object where the container is present.158 * In this case it is the MyPage.159 * 160 * </pre>161 * 162 * </td>163 * </tr>164 * </table>165 * </p>166 */167public abstract class AbstractContainer extends AbstractElement implements ParentTraits {168 private int index;169 protected Map<String, String> containerElements;170 /**171 * Constructs a Container with locator.172 * 173 * @param locator174 * A String that represents the means to locate this element (could be id/name/xpath/css locator).175 * 176 */177 public AbstractContainer(String locator) {178 this(locator, null);179 }180 /**181 * Constructs a Container with locator and controlName.182 * 183 * @param locator184 * A String that represents the means to locate this element (could be id/name/xpath/css locator).185 * @param controlName186 * The control name used for logging.187 */188 public AbstractContainer(String locator, String controlName) {189 this(locator, controlName, null);190 }191 /**192 * Constructs a {@link Container} with locator, controlName and a parent193 * 194 * @param locator195 * A String that represents the means to locate this element (could be id/name/xpath/css locator).196 * @param controlName197 * The control name used for logging.198 * @param parent199 * A {@link ParentTraits} object that represents the parent element for this element.200 */201 public AbstractContainer(String locator, String controlName, ParentTraits parent) {202 super(locator, controlName, parent);203 }204 205 /**206 * Constructs a {@link Container} with locator, controlName, parent and containerElements207 * 208 * @param locator209 * A String that represents the means to locate this element (could be id/name/xpath/css locator).210 * @param controlName211 * The control name used for logging.212 * @param parent213 * A {@link ParentTraits} object that represents the parent element for this element.214 * @param containerElements215 * A {@link Map} containing the locators for elements inside this container.216 */217 public AbstractContainer(String locator, String controlName, ParentTraits parent,Map<String,String> containerElements){218 super(locator,controlName,parent);219 this.containerElements = containerElements; 220 }221 /**222 * Sets the index at which the element will be returned when {@link #getElement()} is called.223 * 224 * @param index225 * The index at which the element will be returned when getElement() is called.226 */227 public void setIndex(int index) {228 this.index = index;229 }230 /**231 * Used to call {@link HtmlElementUtils#locateElements(String) locateElements} and returns the element at current...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeLion automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful