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

Best SeLion code snippet using com.paypal.selion.platform.html.ContainerTest.testContainer

Source:ContainerTest.java Github

copy

Full Screen

...33 private static final String uniqueId = "uniqueId";34 35 @Test(groups = { "browser-tests" })36 @WebTest37 public void testContainerWithXpathBase() {38 Grid.driver().get(TestServerUtils.getContainerURL());39 String baseLocator = "//*[contains(@class,'base')]";40 testContainerWithLocatorTypes(baseLocator);41 }42 @Test(groups = { "browser-tests" })43 @WebTest44 public void testContainerWithCssBase() {45 Grid.driver().get(TestServerUtils.getContainerURL());46 String baseLocator = "css=.base";47 testContainerWithLocatorTypes(baseLocator);48 }49 @Test(groups = { "browser-tests" })50 @WebTest51 public void testContainerWithIdBase() {52 Grid.driver().get(TestServerUtils.getContainerURL());53 String baseLocator = "id=base";54 testContainerWithLocatorTypes(baseLocator);55 }56 @Test(groups = { "browser-tests" })57 @WebTest58 public void testContainerWithNameBase() {59 Grid.driver().get(TestServerUtils.getContainerURL());60 String baseLocator = "name=base";61 testContainerWithLocatorTypes(baseLocator);62 }63 @Test(groups = { "browser-tests" })64 @WebTest65 public void testContainerWithLinkBase() {66 Grid.driver().get(TestServerUtils.getContainerURL());67 String baseLocator = "link=baseLink";68 testContainerWithLocatorTypes(baseLocator);69 }70 private void testContainerWithLocatorTypes(String baseLocator) {71 SampleContainer container = new SampleContainer(baseLocator);72 int totalContainers = container.size();73 verifyEquals(totalContainers, 2);74 for (int i = 0; i <= totalContainers - 1; i++) {75 container.setIndex(i);76 int expectedIndex = i + 1;77 TextField cssChild = container.getCssChild();78 String actualAttributeValue = cssChild.getAttribute(name);79 verifyEquals(actualAttributeValue, uniqueName + expectedIndex, cssChild.getLocator());80 Label idChild = container.getIdChild();81 actualAttributeValue = idChild.getAttribute(name);82 verifyEquals(actualAttributeValue, uniqueName + expectedIndex, idChild.getLocator());83 Image nameChild = container.getNameChild();84 actualAttributeValue = nameChild.getAttribute(id);85 verifyEquals(actualAttributeValue, uniqueId + expectedIndex, nameChild.getLocator());86 // Skip nested links unless an example can be created87 if (!baseLocator.contains("link=")) {88 Link linkChild = container.getLinkChild();89 actualAttributeValue = linkChild.getAttribute(name);90 verifyEquals(actualAttributeValue, uniqueName + expectedIndex, linkChild.getLocator());91 }92 Label xpathChild = container.getXpathChild();93 actualAttributeValue = xpathChild.getAttribute(name);94 verifyEquals(actualAttributeValue, uniqueName + expectedIndex, xpathChild.getLocator());95 }96 }97 @Test(groups = { "browser-tests" })98 @WebTest99 public void testContainer() {100 Grid.driver().get(TestServerUtils.getContainerURL());101 Container container = new Container("id=base");102 String actualName = container.locateElement(1, "css=.dupId").getAttribute(name);103 verifyEquals(actualName, uniqueName + "2");104 }105 @Test(groups = { "browser-tests" })106 @WebTest107 public void testContainerWithSize0() {108 Grid.driver().get(TestServerUtils.getContainerURL());109 SampleContainer container = new SampleContainer("id=doesNotExist");110 verifyTrue(container.size() == 0);111 }112 @Test(groups = { "browser-tests" })113 @WebTest114 public void testContainerNoSuchElementExceptionAtIndex() {115 String failureMsg = "Allowing users to attempt getting elements at an unavailable index.";116 Grid.driver().get(TestServerUtils.getContainerURL());117 SampleContainer container = new SampleContainer("id=doesNotExist");118 container.setIndex(1);119 try {120 container.getCssChild().getElement();121 fail(failureMsg);122 } catch (NoSuchElementException e) {123 // NOSONAR124 }125 try {126 container.getCssChild().getElements();127 fail(failureMsg);128 } catch (NoSuchElementException e) {129 // NOSONAR130 }131 container = new SampleContainer("id=base");132 container.setIndex(5);133 try {134 container.getCssChild().getElement();135 fail(failureMsg);136 } catch (NoSuchElementException e) {137 // NOSONAR138 }139 try {140 container.getCssChild().getElements();141 fail(failureMsg);142 } catch (NoSuchElementException e) {143 // NOSONAR144 }145 }146 @Test(groups = { "browser-tests" })147 @WebTest148 public void testContainerBadChildXpathLocator() {149 String failureMsg = "Allowing users to get child element with bad locator: ";150 Grid.driver().get(TestServerUtils.getContainerURL());151 SampleContainer container = new SampleContainer("id=base");152 try {153 container.getBadXpathLocator1().getElement();154 fail(failureMsg + container.getBadXpathLocator1().getLocator());155 } catch (UnsupportedOperationException e) {156 verifyTrue(true);157 }158 try {159 container.getBadXpathLocator2().getElement();160 fail(failureMsg + container.getBadXpathLocator2().getLocator());161 } catch (UnsupportedOperationException e) {162 verifyTrue(true);163 }164 }165 @Test(groups = { "browser-tests" })166 @WebTest167 public void testLocateElementsInContainer() {168 Grid.open(TestServerUtils.getContainerURL());169 List<WebElement> e = HtmlElementUtils.locateElements("css=.dupId");170 assertEquals(e.size(), 6);171 e = HtmlElementUtils.locateElements("css=#base .dupId");172 assertEquals(e.size(), 2);173 ContainerTest.SampleContainer container = (new ContainerTest()).new SampleContainer("css=#base");174 e = HtmlElementUtils.locateElements("css=.dupId", container);175 assertEquals(e.size(), 1);176 }177 @Test(groups = { "browser-tests" })178 @WebTest179 public void testContainerGetSize() {180 Grid.driver().get(TestServerUtils.getContainerURL());181 AbstractContainer container = new Container("id=base");182 assertTrue(container.size() > 0);183 }184 @Test(groups = { "browser-tests" })185 @WebTest186 public void testLocateChildElement() {187 Grid.driver().get(TestServerUtils.getContainerURL());188 AbstractContainer container = new Container("id=base");189 WebElement childElement = container.locateChildElement("css=.dupId");190 assertTrue(childElement != null);191 List<WebElement> childElements = container.locateChildElements("css=.dupId");192 assertTrue(childElements.size() > 0);193 }...

Full Screen

Full Screen

testContainer

Using AI Code Generation

copy

Full Screen

1public class ContainerTest extends AbstractSeleniumTest {2 public void testContainer() {3 ContainerTest.testContainer();4 }5}6public class ContainerTest extends AbstractSeleniumTest {7 public void testContainer() {8 ContainerTest.testContainer();9 }10}11ContainerTest.testContainer();12 at com.paypal.selion.platform.html.support.HtmlElementUtils.findElement(HtmlElementUtils.java:50)13 at com.paypal.selion.platform.html.support.HtmlElementUtils.findElement(HtmlElementUtils.java:36)14 at com.paypal.selion.platform.html.AbstractElement.getLocator(AbstractElement.java:77)15 at com.paypal.selion.platform.html.AbstractElement.getElement(AbstractElement.java:71)16 at com.paypal.selion.platform.html.AbstractElement.getElement(AbstractElement.java:66)17 at com.paypal.selion.platform.html.AbstractElement.getElement(AbstractElement.java:62)18 at com.paypal.selion.platform.html.AbstractElement.getElement(AbstractElement.java:58)19 at com.paypal.selion.platform.html.AbstractElement.isElementPresent(AbstractElement.java:143)20 at com.paypal.selion.platform.html.AbstractElement.isVisible(AbstractElement.java:129)

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful