How to use SpecContains method of com.galenframework.specs.SpecContains class

Best Galen code snippet using com.galenframework.specs.SpecContains.SpecContains

Source:ContainsValidationTest.java Github

copy

Full Screen

...17import com.galenframework.components.validation.MockedPage;18import com.galenframework.page.Page;19import com.galenframework.page.PageElement;20import com.galenframework.page.Rect;21import com.galenframework.specs.SpecContains;22import com.galenframework.specs.page.Locator;23import com.galenframework.specs.page.PageSpec;24import com.galenframework.validation.PageValidation;25import com.galenframework.validation.ValidationError;26import com.galenframework.validation.ValidationObject;27import org.testng.annotations.DataProvider;28import org.testng.annotations.Test;29import java.util.HashMap;30import java.util.List;31import static java.util.Arrays.asList;32import static org.hamcrest.MatcherAssert.assertThat;33import static org.hamcrest.Matchers.notNullValue;34import static org.hamcrest.core.Is.is;35public class ContainsValidationTest extends ValidationTestBase {36 private static final boolean CONTAINS_FULLY = false;37 private static final boolean CONTAINS_PARTLY = true;38 @Test39 public void spec_contains_should_allow_to_use_object_groups() {40 PageSpec pageSpec = new PageSpec();41 pageSpec.setObjects(new HashMap<String, Locator>(){{42 put("menu", new Locator("css", "#menu"));43 put("menu_item-1", new Locator("css", "#menu li", 1));44 put("menu_item-2", new Locator("css", "#menu li", 2));45 put("menu_item-3", new Locator("css", "#menu li", 3));46 }});47 pageSpec.setObjectGroups(new HashMap<String, List<String>>() {{48 put("menu_items", asList("menu_item-1", "menu_item-2", "menu_item-3"));49 }});50 Page page = new MockedPage(new HashMap<String, PageElement>(){{51 put("menu", element(0, 0, 1000, 50));52 put("menu_item-1", element(0, 0, 100, 50));53 put("menu_item-2", element(0, 0, 100, 50));54 put("menu_item-3", element(0, 100, 100, 50));55 }});56 PageValidation validation = new PageValidation(null, page, pageSpec, null, null);57 ValidationError error = validation.check("menu", new SpecContains(asList("&menu_items"), false)).getError();58 assertThat(error, is(notNullValue()));59 assertThat(error, is(new ValidationError(asList("\"menu_item-3\" is outside \"menu\""))));60 }61 @DataProvider62 @Override63 public Object[][] provideGoodSamples() {64 return new Object[][]{65 {specContains(CONTAINS_FULLY, "menu", "button"), page(new HashMap<String, PageElement>(){{66 put("object", element(10, 10, 100, 100));67 put("menu", element(11, 11, 10, 10));68 put("button", element(60, 50, 40, 40));69 }})},70 {specContains(CONTAINS_PARTLY, "menu", "button"), page(new HashMap<String, PageElement>(){{71 put("object", element(10, 10, 100, 100));72 put("menu", element(50, 50, 300, 10));73 put("button", element(10, 10, 100, 40));74 }})},75 {specContains(CONTAINS_PARTLY, "menu", "button"), page(new HashMap<String, PageElement>(){{76 put("object", element(70, 70, 100, 100));77 put("menu", element(0, 0, 100, 72));78 put("button", element(5, 5, 100, 70));79 }})},80 {specContains(CONTAINS_FULLY, "menu-item-*", "button"), page(new HashMap<String, PageElement>(){{81 put("object", element(0, 0, 200, 100));82 put("menu-item-1", element(10, 10, 10, 10));83 put("menu-item-2", element(30, 10, 10, 10));84 put("menu-item-3", element(50, 10, 10, 10));85 put("button", element(70, 10, 10, 10));86 }})}87 };88 }89 @DataProvider90 @Override91 public Object[][] provideBadSamples() {92 return new Object[][]{93 {validationResult(areas(new ValidationObject(new Rect(9, 11, 10, 10), "menu"), new ValidationObject(new Rect(10, 10, 100, 100), "object")), messages("\"menu\" is outside \"object\"")),94 specContains(false, "menu", "button"), page(new HashMap<String, PageElement>(){{95 put("object", element(10, 10, 100, 100));96 put("menu", element(9, 11, 10, 10));97 put("button", element(60, 50, 40, 40));98 }})},99 {validationResult(areas(new ValidationObject(new Rect(50, 50, 110, 10), "menu"), new ValidationObject(new Rect(10, 10, 101, 40), "button"), new ValidationObject(new Rect(10, 10, 100, 100), "object")), messages("\"menu\" is outside \"object\"", "\"button\" is outside \"object\"")),100 specContains(false, "menu", "button"), page(new HashMap<String, PageElement>(){{101 put("object", element(10, 10, 100, 100));102 put("menu", element(50, 50, 110, 10));103 put("button", element(10, 10, 101, 40));104 }})},105 {validationResult(NO_AREA, messages("\"menu\" is not visible on page")),106 specContains(CONTAINS_FULLY, "menu", "button"), page(new HashMap<String, PageElement>(){{107 put("object", element(10, 10, 100, 100));108 put("menu", invisibleElement(11, 11, 10, 10));109 put("button", element(60, 50, 40, 40));110 }})},111 {validationResult(NO_AREA, messages("\"menu\" is absent on page")),112 specContains(CONTAINS_FULLY, "menu", "button"), page(new HashMap<String, PageElement>(){{113 put("object", element(10, 10, 100, 100));114 put("menu", absentElement(11, 11, 10, 10));115 put("button", element(60, 50, 40, 40));116 }})},117 {validationResult(areas(new ValidationObject(new Rect(350, 10, 10, 10), "menu-item-3"), new ValidationObject(new Rect(0, 0, 200, 100), "object")), messages("\"menu-item-3\" is outside \"object\"")),118 specContains(CONTAINS_FULLY, "menu-item-*", "button"), page(new HashMap<String, PageElement>(){{119 put("object", element(0, 0, 200, 100));120 put("menu-item-1", element(10, 10, 10, 10));121 put("menu-item-2", element(30, 10, 10, 10));122 put("menu-item-3", element(350, 10, 10, 10));123 put("button", element(70, 10, 10, 10));124 }})},125 {validationResult(NO_AREA, messages("There are no objects matching: menu-item-*")),126 specContains(CONTAINS_FULLY, "menu-item-*", "button"), page(new HashMap<String, PageElement>(){{127 put("object", element(0, 0, 200, 100));128 put("button", element(70, 10, 10, 10));129 }})}130 };131 }132 private SpecContains specContains(boolean isPartly, String...objects) {133 return new SpecContains(asList(objects), isPartly);134 }135}...

Full Screen

Full Screen

SpecContains

Using AI Code Generation

copy

Full Screen

1package com.galenframework.java.sample.tests;2import com.galenframework.java.sample.components.GalenTestBase;3import org.testng.annotations.Test;4import java.io.IOException;5public class SpecContainsTest extends GalenTestBase {6 @Test(dataProvider = "devices")7 public void specContainsTest(Device device) throws IOException {

Full Screen

Full Screen

SpecContains

Using AI Code Generation

copy

Full Screen

1SpecContains specContains = new SpecContains("left", "20px");2SpecNotContains specNotContains = new SpecNotContains("left", "20px");3SpecExact specExact = new SpecExact("left", "20px");4SpecNotExact specNotExact = new SpecNotExact("left", "20px");5SpecInside specInside = new SpecInside("left", "20px");6SpecNotInside specNotInside = new SpecNotInside("left", "20px");7SpecNear specNear = new SpecNear("left", "20px");8SpecNotNear specNotNear = new SpecNotNear("left", "20px");

Full Screen

Full Screen

SpecContains

Using AI Code Generation

copy

Full Screen

1import com.galenframework.specs.SpecContains2def spec = new SpecContains("text", "The text to be verified", "area to verify the text")3println spec.getSpecName()4println spec.getArgs()5println spec.toString()6println spec.getSpecName() + " " + spec.getArgs()7println spec.getSpecName() + " " + spec.getArgs().join(" ")

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 Galen automation tests on LambdaTest cloud grid

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

Most used method in SpecContains

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful