Best Galen code snippet using com.galenframework.specs.page.ObjectSpecs.getSpecs
Source:PageSpecReaderTest.java
...99 assertThat(pageSpec.getSections().size(), is(2));100 PageSection section1 = pageSpec.getSections().get(0);101 assertThat(section1.getObjects().size(), is(1));102 assertThat(section1.getObjects().get(0).getObjectName(), is("header"));103 assertThat(section1.getObjects().get(0).getSpecs().size(), is(1));104 assertThat(section1.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("height 100px"));105 assertThat(section1.getSections().size(), is(1));106 PageSection subSection = section1.getSections().get(0);107 assertThat(subSection.getObjects().size(), is(2));108 assertThat(subSection.getObjects().get(0).getObjectName(), is("login-link"));109 assertThat(subSection.getObjects().get(0).getSpecs().size(), is(1));110 assertThat(subSection.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("height 30px"));111 assertThat(subSection.getObjects().get(1).getObjectName(), is("register-link"));112 assertThat(subSection.getObjects().get(1).getSpecs().size(), is(1));113 assertThat(subSection.getObjects().get(1).getSpecs().get(0).getOriginalText(), is("right-of login-link 10 to 30px"));114 PageSection section2 = pageSpec.getSections().get(1);115 assertThat(section2.getName(), is("Main section"));116 assertThat(section2.getObjects().size(), is(1));117 assertThat(section2.getObjects().get(0).getObjectName(), is("main-section"));118 assertThat(section2.getObjects().get(0).getSpecs().size(), is(2));119 assertThat(section2.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("below header 0 to 5px"));120 assertThat(section2.getObjects().get(0).getSpecs().get(1).getOriginalText(), is("inside screen 0px left right"));121 }122 @Test123 public void shouldProcess_complexObjectExpressions_insideSections() throws IOException {124 PageSpec pageSpec = readPageSpec("speclang2/complex-object-expressions.gspec");125 PageSection section = pageSpec.getSections().get(0);126 assertThat(section.getName(), is("Main section"));127 assertThat(section.getObjects().size(), is(6));128 assertThat(section.getPlace(), is(new Place("speclang2/complex-object-expressions.gspec", 16)));129 assertThat(section.getObjects().get(0).getObjectName(), is("header"));130 assertThat(section.getObjects().get(0).getSpecs().size(), is(1));131 assertThat(section.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("inside screen 0px left right"));132 assertThat(section.getObjects().get(1).getObjectName(), is("menu"));133 assertThat(section.getObjects().get(1).getSpecs().size(), is(1));134 assertThat(section.getObjects().get(1).getSpecs().get(0).getOriginalText(), is("inside screen 0px left right"));135 assertThat(section.getObjects().get(2).getObjectName(), is("main"));136 assertThat(section.getObjects().get(2).getSpecs().size(), is(1));137 assertThat(section.getObjects().get(2).getSpecs().get(0).getOriginalText(), is("inside screen 0px left right"));138 assertThat(section.getObjects().get(3).getObjectName(), is("menu-item-1"));139 assertThat(section.getObjects().get(3).getSpecs().size(), is(1));140 assertThat(section.getObjects().get(3).getSpecs().get(0).getOriginalText(), is("height 30px"));141 assertThat(section.getObjects().get(4).getObjectName(), is("menu-item-2"));142 assertThat(section.getObjects().get(4).getSpecs().size(), is(1));143 assertThat(section.getObjects().get(4).getSpecs().get(0).getOriginalText(), is("height 30px"));144 assertThat(section.getObjects().get(5).getObjectName(), is("menu-item-3"));145 assertThat(section.getObjects().get(5).getSpecs().size(), is(1));146 assertThat(section.getObjects().get(5).getSpecs().get(0).getOriginalText(), is("height 30px"));147 }148 @Test149 public void shouldProcess_hashInObjectPattern_asDigits() throws IOException {150 PageSpec pageSpec = readPageSpec("speclang2/hash-in-object-name.gspec");151 PageSection section = pageSpec.getSections().get(0);152 assertThat(section.getObjects().size(), is(2));153 assertThat(section.getObjects().get(0).getObjectName(), is("item-1"));154 assertThat(section.getObjects().get(1).getObjectName(), is("item-342"));155 }156 /**157 * Purpose of this test is to check that "${}" expressions could be processed everywhere158 */159 @Test160 public void shouldRead_variablesDefinition_andProcessThem() throws IOException {161 PageSpec pageSpec = readPageSpec("speclang2/variables-and-processing.gspec");162 assertThat(pageSpec.getSections().size(), is(1));163 assertThat(pageSpec.getSections().get(0).getName(), is("Section for user Johny"));164 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getObjectName(), is("welcome-message"));165 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(0).getOriginalText(), is("text is \"Welcome, Johny\""));166 }167 @Test168 public void shouldRead_simpleForLoop_andProcessIt() throws IOException {169 PageSpec pageSpec = readPageSpec("speclang2/for-loop.gspec");170 assertThat(pageSpec.getSections().size(), is(1));171 assertThat(pageSpec.getSections().get(0).getName(), is("Main section"));172 assertThat(pageSpec.getSections().get(0).getObjects().size(), is(13));173 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();174 int objectIndex = 0;175 for (int i = 1; i <= 3; i++) {176 for (Integer j : asList(5, 7, 9)) {177 assertThat("Object #" + objectIndex + " name should be",178 objects.get(objectIndex).getObjectName(),179 is("box-" + i + "-" + j));180 assertThat("Object #" + objectIndex + " spec should be",181 objects.get(objectIndex).getSpecs().get(0).getOriginalText(),182 is("text is \"" + i + " and " + j + "\""));183 objectIndex++;184 }185 assertThat("Object #" + objectIndex + " name should be",186 objects.get(objectIndex).getObjectName(),187 is("label-" + i));188 assertThat("Object #" + objectIndex + " spec should be",189 objects.get(objectIndex).getSpecs().get(0).getOriginalText(),190 is("height 10px"));191 objectIndex++;192 }193 assertThat("Object #11 name should be",194 objects.get(objectIndex).getObjectName(),195 is("caption"));196 assertThat("Object #11 spec should be",197 objects.get(objectIndex).getSpecs().get(0).getOriginalText(),198 is("width 50px"));199 }200 @Test201 public void shouldRead_eachLoop_andProcessIt() throws IOException {202 PageSpec pageSpec = readPageSpec("speclang2/foreach-loop.gspec");203 assertThat(pageSpec.getSections().size(), is(3));204 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();205 assertThat(objects.size(), is(4));206 for (int i = 0; i < 4; i++) {207 assertThat("Section 1. Object #" + i + " name should be", objects.get(i).getObjectName(),208 is("menu-item-" + (i+1)));209 assertThat("Section 1. Object #" + i + " spec should be", objects.get(i).getSpecs().get(0).getOriginalText(),210 is("width 100px"));211 }212 List<ObjectSpecs> objects2 = pageSpec.getSections().get(1).getObjects();213 assertThat(objects2.size(), is(3));214 for (int i = 0; i < 3; i++) {215 assertThat("Section 2. Object #" + i + " name should be", objects2.get(i).getObjectName(),216 is("menu-item-" + (i+2)));217 assertThat("Section 2. Object #" + i + " spec should be", objects2.get(i).getSpecs().get(0).getOriginalText(),218 is("right-of menu-item-" + (i+1) + " 10px"));219 }220 List<ObjectSpecs> objects3 = pageSpec.getSections().get(2).getObjects();221 assertThat(objects3.size(), is(3));222 for (int i = 0; i < 3; i++) {223 assertThat("Section 3. Object #" + i + " name should be", objects3.get(i).getObjectName(),224 is("menu-item-" + (i+1)));225 assertThat("Section 3. Object #" + i + " spec should be", objects3.get(i).getSpecs().get(0).getOriginalText(),226 is("left-of menu-item-" + (i + 2) + " 10px"));227 }228 }229 /**230 * Comes from https://github.com/galenframework/galen/issues/303231 */232 @Test233 public void shouldRead_emptyLoops_withoutException() throws IOException {234 PageSpec pageSpec = readPageSpec("speclang2/empty-for-loops.gspec", EMPTY_PAGE, EMPTY_TAGS, EMPTY_TAGS);235 assertThat(pageSpec.getSections().size(), is(0));236 }237 @Test238 public void shouldLoopOver_existingAndNonExisting_objects() throws IOException {239 PageSpec pageSpec = readPageSpec("speclang2/foreach-loop-with-nonexisting-objects.gspec");240 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();241 assertThat(objects.size(), is(6));242 assertThat(objects.get(0).getObjectName(), is("menu-item-1"));243 assertThat(objects.get(1).getObjectName(), is("menu-item-2"));244 assertThat(objects.get(2).getObjectName(), is("menu-item-3"));245 assertThat(objects.get(3).getObjectName(), is("header"));246 assertThat(objects.get(4).getObjectName(), is("toolbar"));247 assertThat(objects.get(5).getObjectName(), is("popup"));248 }249 @Test250 public void shouldRead_taggedSections_andProcessOnlyThose_thatMatchGivenTags_1() throws IOException {251 PageSpec pageSpec = readPageSpec("speclang2/tagged-sections.gspec", EMPTY_PAGE, asList("mobile"), EMPTY_TAGS);252 assertThat(pageSpec.getSections().size(), is(1));253 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();254 assertThat(objects.size(), is(2));255 assertThat(objects.get(0).getObjectName(), is("header"));256 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("height 100px"));257 assertThat(objects.get(1).getObjectName(), is("header-icon"));258 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("inside header 5px top left"));259 }260 @Test261 public void shouldRead_taggedSections_andProcessOnlyThose_thatMatchGivenTags_2() throws IOException {262 PageSpec pageSpec = readPageSpec("speclang2/tagged-sections.gspec", EMPTY_PAGE, asList("tablet"), EMPTY_TAGS);263 assertThat(pageSpec.getSections().size(), is(1));264 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();265 assertThat(objects.size(), is(2));266 assertThat(objects.get(0).getObjectName(), is("header"));267 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("height 100px"));268 assertThat(objects.get(1).getObjectName(), is("header-icon"));269 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("inside header 5px top left"));270 }271 @Test272 public void shouldRead_taggedSections_andProcessOnlyThose_thatMatchGivenTags_3() throws IOException {273 PageSpec pageSpec = readPageSpec("speclang2/tagged-sections.gspec", EMPTY_PAGE, asList("desktop"), EMPTY_TAGS);274 assertThat(pageSpec.getSections().size(), is(1));275 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();276 assertThat(objects.size(), is(2));277 assertThat(objects.get(0).getObjectName(), is("header"));278 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("height 200px"));279 assertThat(objects.get(1).getObjectName(), is("header-icon"));280 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("inside header 5px top left"));281 }282 @Test283 public void shouldRead_taggedSections_andExcludeTags() throws IOException {284 PageSpec pageSpec = readPageSpec("speclang2/tagged-sections.gspec", EMPTY_PAGE, asList("mobile", "desktop"), asList("tablet"));285 assertThat(pageSpec.getSections().size(), is(1));286 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();287 assertThat(objects.size(), is(2));288 assertThat(objects.get(0).getObjectName(), is("header"));289 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("height 200px"));290 assertThat(objects.get(1).getObjectName(), is("header-icon"));291 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("inside header 5px top left"));292 }293 @Test294 public void should_importOtherPageSpecs_onlyOnce_andMergeSectionsAndObjects() throws IOException {295 PageSpec pageSpec = readPageSpec("speclang2/import-other-pagespecs.gspec");296 assertThat(pageSpec.getObjects(), is((Map<String, Locator>) new HashMap<String, Locator>() {{297 put("header", new Locator("css", "#header"));298 put("main-container", new Locator("css", "#main"));299 }}));300 assertThat(pageSpec.getSections().size(), is(2));301 assertThat(pageSpec.getSections().get(0).getName(), is("Header section"));302 assertThat(pageSpec.getSections().get(0).getObjects().size(), is(1));303 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getObjectName(), is("header"));304 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().size(), is(2));305 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(0).getOriginalText(), is("inside screen 0px top left right"));306 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(1).getOriginalText(), is("height 100px"));307 assertThat(pageSpec.getSections().get(1).getName(), is("Main section"));308 assertThat(pageSpec.getSections().get(1).getObjects().size(), is(1));309 assertThat(pageSpec.getSections().get(1).getObjects().get(0).getObjectName(), is("main-container"));310 assertThat(pageSpec.getSections().get(1).getObjects().get(0).getSpecs().size(), is(1));311 assertThat(pageSpec.getSections().get(1).getObjects().get(0).getSpecs().get(0).getOriginalText(), is("below header 0px"));312 }313 @Test314 public void shouldImportOtherSpecs_whenMainSpecIsLoaded_fromAbsolutePath() throws IOException {315 PageSpec pageSpec = readPageSpec(new File(getClass().getResource("/speclang2/import-other-pagespecs.gspec").getFile()).getAbsolutePath());316 assertThat(pageSpec.getObjects(), is((Map<String, Locator>) new HashMap<String, Locator>() {{317 put("header", new Locator("css", "#header"));318 put("main-container", new Locator("css", "#main"));319 }}));320 }321 @Test322 public void shouldExecute_customJavaScript_fromSeparateFile() throws IOException {323 PageSpec pageSpec = readPageSpec("speclang2/script-importing.gspec");324 assertThat(pageSpec.getSections().size(), is(1));325 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();326 assertThat(objects.size(), is(2));327 assertThat(objects.get(0).getObjectName(), is("caption"));328 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("text is \"Awesome website!\""));329 assertThat(objects.get(1).getObjectName(), is("caption-2"));330 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("text is \"Welcome, Johny\""));331 }332 @Test333 public void scriptsPath_shouldBeResolved_whenSpecIsLoaded_fromAbsolutePath() throws IOException {334 String absolutePath = new File(getClass().getResource("/speclang2/script-importing.gspec").getFile()).getAbsolutePath();335 PageSpec pageSpec = readPageSpec(absolutePath);336 assertThat(pageSpec.getSections().size(), is(1));337 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();338 assertThat(objects.size(), is(2));339 assertThat(objects.get(0).getObjectName(), is("caption"));340 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("text is \"Awesome website!\""));341 assertThat(objects.get(1).getObjectName(), is("caption-2"));342 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("text is \"Welcome, Johny\""));343 }344 @Test345 public void shouldExecute_inPageJavaScript() throws IOException {346 PageSpec pageSpec = readPageSpec("speclang2/script-inpage.gspec");347 assertThat(pageSpec.getSections().size(), is(1));348 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();349 assertThat(objects.size(), is(2));350 assertThat(objects.get(0).getObjectName(), is("caption"));351 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("text is \"Awesome website!\""));352 assertThat(objects.get(1).getObjectName(), is("caption-2"));353 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("text is \"Welcome, Johny\""));354 }355 @Test(expectedExceptions = SyntaxException.class,356 expectedExceptionsMessageRegExp = "JavaScript error inside statement\n in speclang2/error-in-js-block.gspec:8"357 )358 public void shouldFail_whenThereIsError_inJavaScriptBlock() throws IOException {359 readPageSpec("speclang2/error-in-js-block.gspec",360 new MockedPage(new HashMap<String, PageElement>()),361 EMPTY_TAGS, EMPTY_TAGS);362 }363 @Test364 public void shouldRead_conditionsWithMultipleElseBlocks() throws IOException {365 PageSpec pageSpec = readPageSpec("speclang2/conditions.gspec",366 new MockedPage(new HashMap<String, PageElement>() {{367 put("header", element(0, 0, 100, 10));368 }}),369 EMPTY_TAGS, EMPTY_TAGS);370 assertThat(pageSpec.getSections().size(), is(1));371 PageSection section = pageSpec.getSections().get(0);372 assertThat(section.getObjects().size(), is(1));373 assertThat(section.getObjects().get(0).getObjectName(), is("header-icon"));374 assertThat(section.getObjects().get(0).getSpecs().size(), is(1));375 assertThat(section.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("inside header 10px top left"));376 }377 @Test378 public void shouldRead_conditionsWithMultipleElseBlocks_2() throws IOException {379 PageSpec pageSpec = readPageSpec("speclang2/conditions.gspec",380 new MockedPage(new HashMap<String, PageElement>(){{381 put("header", invisibleElement(0, 0, 100, 10));382 put("header2", element(0, 0, 100, 10));383 }}),384 EMPTY_TAGS, EMPTY_TAGS);385 assertThat(pageSpec.getSections().size(), is(1));386 PageSection section = pageSpec.getSections().get(0);387 assertThat(section.getObjects().size(), is(1));388 assertThat(section.getObjects().get(0).getObjectName(), is("header2-icon"));389 assertThat(section.getObjects().get(0).getSpecs().size(), is(1));390 assertThat(section.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("inside header2 5px top left"));391 }392 @Test393 public void shouldRead_conditionsWithMultipleElseBlocks_3() throws IOException {394 PageSpec pageSpec = readPageSpec("speclang2/conditions.gspec",395 new MockedPage(new HashMap<String, PageElement>(){{396 put("header", invisibleElement(0, 0, 100, 10));397 put("header2", invisibleElement(0, 0, 100, 10));398 }}),399 EMPTY_TAGS, EMPTY_TAGS);400 assertThat(pageSpec.getSections().size(), is(1));401 PageSection section = pageSpec.getSections().get(0);402 assertThat(section.getObjects().size(), is(1));403 assertThat(section.getObjects().get(0).getObjectName(), is("header3"));404 assertThat(section.getObjects().get(0).getSpecs().size(), is(1));405 assertThat(section.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("visible"));406 }407 @Test(expectedExceptions = SyntaxException.class,408 expectedExceptionsMessageRegExp = "JavaScript error inside statement\n in speclang2/condition-with-js-error.gspec:5"409 )410 public void shouldFail_whenThereIsAnError_insideIfStatement() throws IOException {411 readPageSpec("speclang2/condition-with-js-error.gspec",412 new MockedPage(new HashMap<String, PageElement>()),413 EMPTY_TAGS, EMPTY_TAGS);414 }415 @Test416 public void shouldAllow_toPassProperties() throws IOException {417 Properties properties = new Properties();418 properties.put("custom.user.name", "John");419 PageSpec pageSpec = new PageSpecReader().read("speclang2/properties.gspec", EMPTY_PAGE, new SectionFilter(EMPTY_TAGS, EMPTY_TAGS), properties, NO_VARS, EMPTY_OBJECTS);420 assertThat(pageSpec.getSections().get(0).getName(), is("Main section for user John"));421 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(0).getOriginalText(),422 is("text is \"Welcome, John!\""));423 }424 @Test(expectedExceptions = SyntaxException.class,425 expectedExceptionsMessageRegExp = "\\QExpecting \"px\", \"to\" or \"%\", got \"\"\n in \\E.*speclang2/syntax-error.gspec:9")426 public void shouldThrow_fileSyntaxException_ifThereIsAnErrorInSpec() throws IOException {427 readPageSpec("speclang2/syntax-error.gspec");428 }429 @Test430 public void shouldAllow_mathExpressions_onIntegerValues_onForLoopIndexes() throws IOException {431 PageSpec pageSpec = readPageSpec("speclang2/for-loop-math-expression.gspec");432 PageSection section = pageSpec.getSections().get(0);433 assertThat(section.getObjects().size(), is(4));434 assertThat(section.getObjects().get(0).getSpecs().get(0).getOriginalText(),435 is("right-of menu-item-3"));436 assertThat(section.getObjects().get(1).getSpecs().get(0).getOriginalText(),437 is("right-of menu-item-5"));438 assertThat(section.getObjects().get(2).getSpecs().get(0).getOriginalText(),439 is("right-of menu-item-7"));440 assertThat(section.getObjects().get(3).getSpecs().get(0).getOriginalText(),441 is("right-of menu-item-9"));442 }443 @Test444 public void shouldParse_forLoops_withIfStatements() throws IOException {445 PageSpec pageSpec = readPageSpec("speclang2/for-with-if.gspec");446 PageSection section = pageSpec.getSections().get(0);447 assertThat(section.getObjects().size(), is(1));448 assertThat(section.getObjects().get(0).getSpecs().size(), is(2));449 assertThat(section.getObjects().get(0).getObjectName(),450 is("button"));451 assertThat(section.getObjects().get(0).getSpecs().get(0).getOriginalText(),452 is("inside container1 10px top left"));453 assertThat(section.getObjects().get(0).getSpecs().get(1).getOriginalText(),454 is("inside container2 10px top left"));455 }456 @Test457 public void shouldRead_specsWithWarningLevel() throws IOException {458 PageSpec pageSpec = readPageSpec("speclang2/warning-level-in-specs.gspec");459 PageSection section = pageSpec.getSections().get(0);460 assertThat(section.getObjects().get(0).getSpecs().get(0).isOnlyWarn(), is(false));461 assertThat(section.getObjects().get(0).getSpecs().get(0).getOriginalText(), is("width 100px"));462 assertThat(section.getObjects().get(0).getSpecs().get(1).isOnlyWarn(), is(true));463 assertThat(section.getObjects().get(0).getSpecs().get(1).getOriginalText(), is("height 100px"));464 }465 @Test466 public void shouldRead_specAliases_beforeActualSpecs() throws IOException {467 PageSpec pageSpec = readPageSpec("speclang2/spec-notes.gspec");468 PageSection section = pageSpec.getSections().get(0);469 assertThat(section.getObjects().size(), is(1));470 ObjectSpecs object = section.getObjects().get(0);471 assertThat(object.getSpecs().size(), is(3));472 assertThat(object.getSpecs().get(0).getAlias(), is(nullValue()));473 assertThat(object.getSpecs().get(0).getOriginalText(), is("height 100px"));474 assertThat(object.getSpecs().get(1).getAlias(), is("should be visible"));475 assertThat(object.getSpecs().get(1).getOriginalText(), is("visible"));476 assertThat(object.getSpecs().get(2).getAlias(), is("should be on top"));477 assertThat(object.getSpecs().get(2).getOriginalText(), is("inside screen 0px top"));478 }479 @Test480 public void shouldAllow_toPassCustomJsObjects() throws IOException {481 PageSpec pageSpec = new PageSpecReader().read(482 "speclang2/custom-js-variables.gspec",483 EMPTY_PAGE,484 new SectionFilter(EMPTY_TAGS, EMPTY_TAGS),485 NO_PROPERTIES,486 new HashMap<String, Object>() {{487 put("age", 29);488 put("userName", "John");489 }}, EMPTY_OBJECTS);490 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecs().get(0).getOriginalText(),491 is("text is \"Name: John, age: 29\""));492 }493 @Test494 public void shouldClean_emptySetions() throws IOException {495 PageSpec pageSpec = readPageSpec("speclang2/empty-sections.gspec");496 assertThat(pageSpec.getSections().size(), is(1));497 PageSection section = pageSpec.getSections().get(0);498 assertThat(section.getSections().size(), is(0));499 assertThat(section.getObjects().size(), is(1));500 }501 @Test502 public void countFunction_shouldCountAllMatchingObjects() throws IOException {503 PageSpec pageSpec = readPageSpec("speclang2/count.gspec");504 assertThat(pageSpec.getSections().size(), is(2));505 assertThat(pageSpec.getSections().get(0).getObjects().size(), is(6));506 assertThat(pageSpec.getSections().get(1).getObjects().size(), is(3));507 }508 @Test509 public void forEachLoop_shouldOrderCorrectly_objectsWithNumbers() throws IOException {510 PageSpec pageSpec = readPageSpec("speclang2/foreach-sortorder.gspec");511 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();512 assertThat(objects.size(), is(4));513 assertThat(objects.get(0).getObjectName(), is("menu-item-1"));514 assertThat(objects.get(1).getObjectName(), is("menu-item-2"));515 assertThat(objects.get(2).getObjectName(), is("menu-item-12"));516 assertThat(objects.get(3).getObjectName(), is("menu-item-101"));517 }518 @Test519 public void forEachLoop_shouldAllow_toUseIndex() throws IOException {520 PageSpec pageSpec = readPageSpec("speclang2/forEach-loop-with-index.gspec");521 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();522 assertThat(objects.size(), is(3));523 assertThat(objects.get(0).getObjectName(), is("item-1"));524 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("inside screen 100px top"));525 assertThat(objects.get(1).getObjectName(), is("item-2"));526 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("inside screen 200px top"));527 assertThat(objects.get(2).getObjectName(), is("item-3"));528 assertThat(objects.get(2).getSpecs().get(0).getOriginalText(), is("inside screen 300px top"));529 }530 @Test531 public void shouldAllow_toProvideObjects_toPageSpec() throws IOException {532 Map<String, Locator> objects = new HashMap<>();533 objects.put("header", new Locator("css", "#header"));534 objects.put("menu", new Locator("id", "menu"));535 PageSpec pageSpec = new PageSpecReader().read("speclang2/provide-objects.gspec", EMPTY_PAGE, new SectionFilter(EMPTY_TAGS, EMPTY_TAGS), NO_PROPERTIES, NO_VARS, objects);536 assertThat(pageSpec.getObjects(), allOf(537 hasEntry("header", new Locator("css", "#header")),538 hasEntry("menu", new Locator("id", "menu")),539 hasEntry("button", new Locator("css", "#button"))540 ));541 }542 @Test543 public void customRules_shouldAllow_toUse_ruleBodies_inSpecs() throws IOException {544 PageSpec pageSpec = readPageSpec("speclang2/custom-rules-using-rule-body.gspec",545 new MockedPage(new HashMap<String, PageElement>(){{546 put("banner-1", element(0, 0, 100, 10));547 put("banner-2", invisibleElement(0, 0, 100, 10));548 }}),549 EMPTY_TAGS, EMPTY_TAGS);550 assertThat(pageSpec.getSections().get(0).getObjects().size(), is(1));551 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecGroups().size(), is(1));552 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecGroups().get(0).getSpecs().get(0).getOriginalText(), is("height 90px"));553 assertThat(pageSpec.getSections().get(0).getSections().size(), is(2));554 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getSections().get(0).getObjects();555 assertThat(objects.size(), is(1));556 assertThat(objects.get(0).getObjectName(), is("banner-1"));557 assertThat(objects.get(0).getSpecs().size(), is(1));558 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("width 145px"));559 objects = pageSpec.getSections().get(0).getSections().get(1).getObjects();560 assertThat(objects.size(), is(1));561 assertThat(objects.get(0).getObjectName(), is("banner-3"));562 assertThat(objects.get(0).getSpecs().size(), is(1));563 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("visible"));564 }565 @Test566 public void shouldRead_objectClasses_inObjectsSection() throws IOException {567 PageSpec pageSpec = readPageSpec("speclang2/object-groups-definition.gspec");568 assertThat(pageSpec.getObjectGroups(), hasEntry("image-validation", asList("menu.item-1", "button")));569 assertThat(pageSpec.getObjectGroups(), hasEntry("menu-stuff", asList("menu.item-1")));570 }571 @Test572 public void shouldApply_objectGroups_toAlreadyProcessedObjects() throws IOException {573 PageSpec pageSpec = readPageSpec("speclang2/object-groups-added.gspec");574 assertThat(pageSpec.getObjectGroups(), hasEntry("groupA", asList("obj1", "obj3")));575 assertThat(pageSpec.getObjectGroups(), hasEntry("groupB", asList("obj1", "obj3")));576 assertThat(pageSpec.getObjectGroups(), hasEntry("groupC", asList("obj1", "obj2", "obj3")));577 }578 @Test579 public void countFunction_shouldWorkWithGroups() throws IOException {580 PageSpec pageSpec = readPageSpec("speclang2/count-grouped-objects.gspec");581 assertThat(firstAppearingSpecIn(pageSpec), is("text is \"count is 4\""));582 }583 @Test584 public void findFunction_shouldWorkWithGroups() throws IOException {585 PageSpec pageSpec = readPageSpec("speclang2/find-grouped-object.gspec");586 assertThat(firstAppearingObjectIn(pageSpec).getObjectName(), is("menu_item-1"));587 }588 @Test589 public void firstFunction_shouldWorkWithGroups() throws IOException {590 PageSpec pageSpec = readPageSpec("speclang2/first-grouped-object.gspec");591 assertThat(firstAppearingObjectIn(pageSpec).getObjectName(), is("menu_item-1"));592 }593 @Test594 public void lastFunction_shouldWorkWithGroups() throws IOException {595 PageSpec pageSpec = readPageSpec("speclang2/last-grouped-object.gspec");596 assertThat(firstAppearingObjectIn(pageSpec).getObjectName(), is("menu_icon"));597 }598 @Test599 public void shouldFind_allObjects_forSpecifiedGroups_inRegularObjectStatement() throws IOException {600 PageSpec pageSpec = readPageSpec("speclang2/object-groups-search.gspec");601 assertSearchAndForEachGroupsElements(pageSpec);602 }603 @Test604 public void shouldFind_allObjects_forSpecifiedGroups_forEachLoop() throws IOException {605 PageSpec pageSpec = readPageSpec("speclang2/object-groups-foreach.gspec");606 assertSearchAndForEachGroupsElements(pageSpec);607 }608 private void assertSearchAndForEachGroupsElements(PageSpec pageSpec) {609 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();610 assertThat(objects.size(), is(2));611 assertThat(objects.get(0).getObjectName(), is("cancel-button"));612 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("height 30px"));613 assertThat(objects.get(1).getObjectName(), is("login-button"));614 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("height 30px"));615 }616 @Test617 public void shouldFind_allObjects_forSpecifiedGroups_inJavaScriptFindAllFunction() throws IOException {618 PageSpec pageSpec = readPageSpec("speclang2/object-groups-findAll.gspec",619 new MockedPage(new HashMap<String, PageElement>()),620 EMPTY_TAGS, EMPTY_TAGS);621 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();622 assertThat(objects.size(), is(2));623 assertThat(objects.get(0).getObjectName(), is("cancel-button"));624 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is("height 30px"));625 assertThat(objects.get(1).getObjectName(), is("login-button"));626 assertThat(objects.get(1).getSpecs().get(0).getOriginalText(), is("height 30px"));627 }628 /**629 * When nonexisting object is passed to findAll function - it should return an instance of JsPageElement that630 * will give 0 for any location related values like width, height, right etc. Also it should return false for631 * isVisible function.632 * @throws IOException633 */634 @Test635 public void findAll_andFind_functions_shouldHave_strictObjectProcessing_likeForEachLoop() throws IOException {636 PageSpec pageSpec = readPageSpec("speclang2/findAll-nonexisting-objects.gspec");637 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();638 assertThat(objects.size(), is(1));639 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is(640 "text is \"header[0, 0, 0, 0, false], menu[0, 0, 0, 0, false]\""641 ));642 assertThat(objects.get(0).getSpecs().get(1).getOriginalText(), is(643 "text is \"header[0, 0, 0, 0, false]\""644 ));645 }646 @Test647 public void screenAndViewportObjects_shouldBeAccessible_fromJavaScript_codeBlocks() throws IOException {648 MockedDriver driver = new MockedDriver();649 driver.setExpectedJavaScriptReturnValues(asList(650 (Object)asList(1000L, 700L),651 (Object)asList(900L, 700L)652 ));653 PageSpec pageSpec = readPageSpec("speclang2/screen-and-viewport-from-js.gspec", new SeleniumPage(driver));654 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();655 assertThat(objects.size(), is(1));656 assertThat(objects.get(0).getSpecs().get(0).getOriginalText(), is(657 "width 120 px"658 ));659 }660 @Test661 public void shouldAllowToInvoke_first_function() throws IOException {662 PageSpec pageSpec = readPageSpec("speclang2/first-function.gspec");663 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();664 assertThat(objects.size(), is(1));665 assertThat(objects.get(0).getObjectName(), is("menu_item-1"));666 }667 @Test668 public void shouldAllowToInvoke_last_function() throws IOException {669 PageSpec pageSpec = readPageSpec("speclang2/last-function.gspec");670 List<ObjectSpecs> objects = pageSpec.getSections().get(0).getObjects();671 assertThat(objects.size(), is(1));672 assertThat(objects.get(0).getObjectName(), is("menu_item-3"));673 }674 @Test675 public void ruleShouldAllows_toUseColon_atTheEnd() throws IOException {676 PageSpec pageSpec = readPageSpec("speclang2/rule-colon-at-end.gspec");677 assertThat(pageSpec.getSections().size(), is(1));678 assertThat(pageSpec.getSections().get(0).getObjects().size(), is(0));679 assertThat(pageSpec.getSections().get(0).getSections().size(), is(1));680 assertThat(pageSpec.getSections().get(0).getSections().get(0).getObjects().size(), is(1));681 ObjectSpecs object = pageSpec.getSections().get(0).getSections().get(0).getObjects().get(0);682 assertThat(object.getObjectName(), is("menu_item-1"));683 assertThat(object.getSpecs().size(), is(1));684 assertThat(object.getSpecs().get(0).getOriginalText(), is("width 100px"));685 }686 @Test687 public void ruleShouldHave_priorityOverRules_thatWereDeclaredFirst() throws IOException {688 PageSpec pageSpec = readPageSpec("speclang2/rule-priority.gspec");689 assertThat(pageSpec.getSections().size(), is(1));690 assertThat(pageSpec.getSections().get(0).getObjects().size(), is(1));691 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getObjectName(), is("cancel_button"));692 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecGroups().size(), is(1));693 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecGroups().get(0).getSpecs().size(), is(1));694 assertThat(pageSpec.getSections().get(0).getObjects().get(0).getSpecGroups().get(0).getSpecs().get(0).getOriginalText(), is("width 30px"));695 assertThat(pageSpec.getSections().get(0).getSections().size(), is(1));696 assertThat(pageSpec.getSections().get(0).getSections().get(0).getObjects().size(), is(1));697 ObjectSpecs object = pageSpec.getSections().get(0).getSections().get(0).getObjects().get(0);698 assertThat(object.getObjectName(), is("login_button"));699 assertThat(object.getSpecs().size(), is(1));700 assertThat(object.getSpecs().get(0).getOriginalText(), is("width 300px"));701 }702 @Test(expectedExceptions = SyntaxException.class,703 expectedExceptionsMessageRegExp = "\\QError processing rule: button is located at the left side inside main_container with 10px margin\\E\\s+\\Qin speclang2/rule-error.gspec:7\\E")704 public void shouldThrownInformativeError_whenThereIsProblemParsingTheRule() throws IOException {705 readPageSpec("speclang2/rule-error.gspec");706 }707 @Test(expectedExceptions = SyntaxException.class,708 expectedExceptionsMessageRegExp = "\\QError processing rule: is located at the left side inside main_container with 10px margin\\E\\s+\\Qin speclang2/rule-error-object-level.gspec:7\\E")709 public void shouldThrownInformativeError_whenThereIsProblemParsingTheRule_inObjectLevel() throws IOException {710 readPageSpec("speclang2/rule-error-object-level.gspec");711 }712 @Test(expectedExceptions = SyntaxException.class,713 expectedExceptionsMessageRegExp = "\\QSpecs cannot have inner blocks\\E\\s+\\Qin speclang2/incorrect/nested-spec.gspec:7\\E")714 public void shouldGiveError_whenSpecIsNested_belowAnotherSpec() throws IOException {...
Source:ExpectedSpecObject.java
...40 public ExpectedSpecObject withSpecs(String...specs) {41 this.specs = asList(specs);42 return this;43 }44 public List<String> getSpecs() {45 return specs;46 }47 public static List<ExpectedSpecObject> convertSection(PageSection pageSection) {48 List<ExpectedSpecObject> objects = new LinkedList<>();49 for (ObjectSpecs objectSpecs : pageSection.getObjects()) {50 ExpectedSpecObject object = convertExpectedSpecObject(objectSpecs);51 objects.add(object);52 }53 return objects;54 }55 private static ExpectedSpecObject convertExpectedSpecObject(ObjectSpecs objectSpecs) {56 ExpectedSpecObject object = new ExpectedSpecObject(objectSpecs.getObjectName());57 List<String> specs = convertSpecs(objectSpecs.getSpecs());58 object.setSpecs(specs);59 Map<String, List<String>> specGroups = new HashMap<String, List<String>>();60 for (SpecGroup specGroup : objectSpecs.getSpecGroups()) {61 specGroups.put(specGroup.getName(), convertSpecs(specGroup.getSpecs()));62 }63 object.setSpecGroups(specGroups);64 return object;65 }66 private static List<String> convertSpecs(List<Spec> originalSpecs) {67 List<String> specs = new LinkedList<>();68 for (Spec spec : originalSpecs) {69 specs.add(spec.getOriginalText());70 }71 return specs;72 }73 public String getExpectedName() {74 return expectedName;75 }...
getSpecs
Using AI Code Generation
1package tests;2import java.io.IOException;3import java.util.List;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.chrome.ChromeOptions;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.testng.annotations.Test;9import com.galenframework.api.Galen;10import com.galenframework.reports.TestReport;11import com.galenframework.specs.page.ObjectSpecs;12import com.galenframework.specs.page.PageSpec;13import com.galenframework.validation.ValidationResult;14public class GalenTest {15 public void galenTest() throws IOException {16 WebDriver driver = new ChromeDriver();17 TestReport report = Galen.createTestReport();18 PageSpec pageSpec = Galen.getPageSpec("specs/homepage.spec");19 ObjectSpecs objectSpecs = pageSpec.getObjectSpecs();20 List<String> objectSpecsList = objectSpecs.getSpecs();21 System.out.println(objectSpecsList);22 driver.quit();23 }24}25package tests;26import java.io.IOException;27import java.util.List;28import org.openqa.selenium.WebDriver;29import org.openqa.selenium.chrome.ChromeDriver;30import org.openqa.selenium.chrome.ChromeOptions;31import org.openqa.selenium.remote.DesiredCapabilities;32import org.testng.annotations.Test;33import com.galenframework.api.Galen;34import com.galenframework.reports.TestReport;35import com.galenframework.specs.page.ObjectSpecs;36import com.galenframework.specs.page.PageSpec;37import com.galenframework.validation.ValidationResult;38public class GalenTest {39 public void galenTest() throws IOException {40 WebDriver driver = new ChromeDriver();41 TestReport report = Galen.createTestReport();42 PageSpec pageSpec = Galen.getPageSpec("specs/homepage.spec");43 ObjectSpecs objectSpecs = pageSpec.getObjectSpecs();44 List<String> objectSpecsList = objectSpecs.getSpecs();45 System.out.println(objectSpecsList);46 driver.quit();47 }48}
getSpecs
Using AI Code Generation
1package com.galenframework.specs;2import java.util.List;3import java.util.Map;4import org.openqa.selenium.By;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.support.ui.ExpectedConditions;9import org.openqa.selenium.support.ui.WebDriverWait;10import com.galenframework.specs.page.ObjectSpecs;11public class GalenSpecs {12public static void main(String[] args) throws Exception {13System.setProperty("webdriver.chrome.driver", "C:\\Users\\shashank\\Downloads\\chromedriver_win32\\chromedriver.exe");14WebDriver driver = new ChromeDriver();15driver.manage().window().maximize();16WebDriverWait wait = new WebDriverWait(driver, 30);17Map<String, List<ObjectSpecs>> specs = ObjectSpecs.getSpecs(search);18System.out.println(specs);19driver.quit();20}21}22{input=[{type=INPUT, name=q, value=, placeholder=Search, tag=input, text=, class=gsfi, id=lst-ib, size=31, maxlength=2048, position=RECTANGLE(0, 0, 0, 0), display=DISPLAY_BLOCK, visibility=VISIBLE, location=POINT(0, 0), size=SIZE(0, 0), rect=RECTANGLE(0, 0, 0, 0), offset=POINT(0, 0), margin=RECTANGLE(0, 0, 0, 0), padding=RECTANGLE(0, 0, 0, 0), css=CSS{background-color=rgba(255, 255, 255, 1), border-color=rgba(0, 0, 0, 1), border-style=solid, border-width=1px, color=rgba(0, 0, 0, 1), font-family=arial, sans-serif, font-size=16px, font-weight=normal, height=39px, line-height=normal, margin-bottom=0px, margin-left=0px, margin-right=0px, margin-top=0px, padding-bottom=0px,
getSpecs
Using AI Code Generation
1package com.galenframework.java.sample;2import java.io.IOException;3import java.util.List;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import com.galenframework.specs.page.ObjectSpecs;7public class GetObjectSpecs {8 public static void main(String[] args) throws IOException {9 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Galen\\Desktop\\chromedriver.exe");10 WebDriver driver = new ChromeDriver();11 ObjectSpecs objectSpecs = new ObjectSpecs();12 List<String> specs = objectSpecs.getSpecs(driver, "input[name='q']");13 System.out.println("Specs for the object are: " + specs);14 driver.close();15 }16}17package com.galenframework.java.sample;18import java.io.IOException;19import java.util.List;20import org.openqa.selenium.WebDriver;21import org.openqa.selenium.chrome.ChromeDriver;22import com.galenframework.specs.page.PageSpecs;23public class GetPageSpecs {24 public static void main(String[] args) throws IOException {25 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Galen\\Desktop\\chromedriver.exe");26 WebDriver driver = new ChromeDriver();27 PageSpecs pageSpecs = new PageSpecs();28 List<String> specs = pageSpecs.getSpecs(driver);29 System.out.println("Specs for the page are: " + specs);30 driver.close();31 }32}33package com.galenframework.java.sample;34import java.io.IOException;35import java.util.List;36import org.openqa.selenium.WebDriver;37import org.openqa.selenium.chrome.ChromeDriver;38import com.galenframework.specs.page.SectionSpecs;39public class GetSectionSpecs {40 public static void main(String[] args) throws IOException {41 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Galen\\Desktop\\chromedriver.exe");42 WebDriver driver = new ChromeDriver();43 SectionSpecs sectionSpecs = new SectionSpecs();44 List<String> specs = sectionSpecs.getSpecs(driver
getSpecs
Using AI Code Generation
1import com.galenframework.specs.page.ObjectSpecs;2import com.galenframework.specs.page.PageSpec;3import com.galenframework.specs.page.PageSpecReader;4import com.galenframework.specs.page.SectionFilter;5import com.galenframework.browser.Browser;6import com.galenframework.browser.SeleniumBrowser;7import com.galenframework.browser.SeleniumBrowserFactory;8import com.galenframework.browser.SeleniumBrowserFactory;9import org.openqa.selenium.WebDriver;10import org.openqa.selenium.chrome.ChromeDriver;11import com.galenframework.reports.TestReport;12import com.galenframework.reports
getSpecs
Using AI Code Generation
1import com.galenframework.specs.page.ObjectSpecs;2import com.galenframework.specs.page.PageSpec;3import com.galenframework.specs.page.PageSpecReader;4import com.galenframework.browser.Browser;5import com.galenframework.browser.SeleniumBrowser;6import com.galenframework.browser.SeleniumBrowserFactory;7import com.gale
getSpecs
Using AI Code Generation
1import java.util.List;2import com.galenframework.specs.Spec;3import com.galenframework.specs.page.ObjectSpecs;4import com.galenframework.browser.SeleniumBrowser;5import com.galenframework.specs.page.Locator;6import com.galenframework.specs.page.PageSpec;7import com.galenframework.specs.page.PageSection;8import com.galenframework.specs.page.PageSectionSpec;9import com.galenframework.specs.page.PageSectionSpecs;10import com.galenframework.specs.page.PageSections;11import com.galenframework.specs.page.PageSectionsSpec;12import com.galenframework.specs.page.PageSectionsSpecs;13import org.openqa.selenium.WebDriver;14import org.openqa.selenium.chrome.ChromeDriver;15import org.openqa.selenium.chrome.ChromeOptions;16import org.openqa.selenium.remote.DesiredCapabilities;17import org.openqa.selenium.remote.RemoteWebDriver;18import org.openqa.selenium.Dimension;19import org.openqa.selenium.Point;20import org.openqa.selenium.WebElement;21import org.openqa.selenium.By;22import org.openqa.selenium.JavascriptExecutor;23import java.util.concurrent.TimeUnit;24import java.util.HashMap;25import java.util.Map;26import java.util.ArrayList;27import java.util.List;28import java.util.Set;29import java.util.Iterator;30import java.util.Map.Entry;31import java.util.concurrent.TimeUnit;32import java.util.regex.Matcher;33import java.util.regex.Pattern;34import java.util.regex.PatternSyntaxException;35import java.util.*;36import java.util.regex.*;37import java.util.concurrent.TimeUnit;38import java.util.concurrent.TimeoutException;39import java.util.concurrent.ExecutionException;40import java.util.function.Function;41import java.util.logging.Level;42import java.util.logging.Logger;43import java.io.*;44import java.io.File;45import java.io.FileInputStream;46import java.io.IOException;47import java.io.InputStream;48import java.io.InputStreamReader;49import java.io.OutputStream;50import java.io.Reader;51import java.net.URL;52import java.nio.charset.Charset;53import java.nio.file.Files;54import java.nio.file.Paths;55import java.util.stream.Collectors;56import java.util.stream.Stream;57import org.apache.commons.io.FileUtils;58import org.apache.commons.io.IOUtils;59import org.apache.commons.io.LineIterator;60import org.apache.commons.io.output.ByteArrayOutputStream;61import org.json.*;62import org.openqa.selenium.Alert;63import org.openqa.selenium.By;64import org.openqa.selenium.Capabilities;65import org.openqa.selenium.Cookie;66import org.openqa.selenium.HasCapabilities;67import org.openqa.selenium.JavascriptExecutor;68import org.openqa.selenium.Keys;69import org.openqa.selenium.NoSuchElementException;70import org.openqa.selenium.OutputType;71import org
getSpecs
Using AI Code Generation
1package com.galenframework.java.sample.tests;2import java.io.IOException;3import java.util.List;4import org.openqa.selenium.By;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.firefox.FirefoxDriver;8import com.galenframework.specs.Spec;9import com.galenframework.specs.page.ObjectSpecs;10public class GetSpecs {11 public static void main(String[] args) throws IOException {12 WebDriver driver = new FirefoxDriver();13 WebElement element = driver.findElement(By.name("q"));14 ObjectSpecs objectSpecs = ObjectSpecs.getSpecs(element);15 List<Spec> specs = objectSpecs.getSpecs();16 for (Spec spec : specs) {17 System.out.println(spec.toString());18 }19 driver.quit();20 }21}22package com.galenframework.java.sample.tests;23import java.io.IOException;24import java.util.List;25import org.openqa.selenium.By;26import org.openqa.selenium.WebDriver;27import org.openqa.selenium.WebElement;28import org.openqa.selenium.firefox.FirefoxDriver;29import com.galenframework.specs.Spec;30import com.galenframework.specs.page.ObjectSpecs;31public class GetSpecs {32 public static void main(String[] args) throws IOException {33 WebDriver driver = new FirefoxDriver();34 WebElement element = driver.findElement(By.name("q"));35 ObjectSpecs objectSpecs = ObjectSpecs.getSpecs(element);36 List<Spec> specs = objectSpecs.getSpecs();37 for (Spec spec : specs) {38 System.out.println(spec.toString());39 }40 driver.quit();41 }42}43package com.galenframework.java.sample.tests;44import java.io.IOException;45import java.util.List;46import org.openqa.selenium.By;47import org.openqa.selenium.WebDriver;48import org.openqa.selenium.WebElement;49import org.openqa.selenium.firefox.FirefoxDriver;50import com.galenframework.specs.Spec;51import com.galenframework.specs.page.ObjectSpecs;
getSpecs
Using AI Code Generation
1import com.galenframework.specs.page.ObjectSpecs;2public class 1 {3 public static void main(String[] args) throws Exception {4 ObjectSpecs objectSpecs = new ObjectSpecs();5 List<Spec> specList = objectSpecs.getSpecs("objectName");6 System.out.println(specList);7 }8}
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!!