How to use element.clear method in Appium

Best JavaScript code snippet using appium

decent-sticky-spec.js

Source:decent-sticky-spec.js Github

copy

Full Screen

1describe("DecentSticky: Creating and showing sticky notes.", function() {2 describe("DecentSticky.getPotentialLocations: Determining possible areas in which the sticky can reside.", function() {3 describe("when the target object is smallish", function() {4 it("returns the correct location to the top", function() {5 var result = DecentSticky.getPotentialLocations(100, 110, 110, 100, 50, 200);6 expect(result[0]).toEqual(jasmine.objectContaining({7 top: 40,8 right: 205,9 left: 5,10 bottom: 9011 }));12 });13 it("returns the correct location to the right", function() {14 var result = DecentSticky.getPotentialLocations(100, 110, 110, 100, 50, 200);15 expect(result[3]).toEqual(jasmine.objectContaining({16 top: 80,17 right: 320,18 left: 120,19 bottom: 13020 }));21 });22 it("returns the correct location to the bottom", function() {23 var result = DecentSticky.getPotentialLocations(100, 110, 110, 100, 50, 200);24 expect(result[6]).toEqual(jasmine.objectContaining({25 top: 120,26 right: 205,27 left: 5,28 bottom: 17029 }));30 });31 it("returns the correct location to the left", function() {32 var result = DecentSticky.getPotentialLocations(100, 110, 110, 100, 50, 200);33 expect(result[7]).toEqual(jasmine.objectContaining({34 top: 80,35 right: 90,36 left: -110,37 bottom: 13038 }));39 });40 });41 });42});43describe("DecentStickyAction: Representing sticky note actions.", function() {44 describe("contravenes: determining when two actions contravene each other", function() {45 var oneAction, anotherAction,46 oneElement, anotherElement,47 testSubject = function() {48 return oneAction.contravenes(anotherAction);49 };50 describe("when the actions have to do with the same element", function() {51 beforeEach(function() {52 oneElement = affix('#div').get(0);53 anotherElement = oneElement;54 });55 describe("when one action is clearing", function() {56 beforeEach(function() {57 oneAction = new DecentStickyAction(function() {}, oneElement, 'clear');58 });59 describe("when the other action is clearing", function() {60 beforeEach(function() {61 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');62 });63 it("doesn't contravene", function() {64 expect(testSubject()).not.toBeTruthy();65 });66 });67 describe("when the other action is hiding", function() {68 beforeEach(function() {69 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');70 });71 it("doesn't contravene", function() {72 expect(testSubject()).not.toBeTruthy();73 });74 });75 describe("when the other action is showing", function() {76 beforeEach(function() {77 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');78 });79 it("contravenes", function() {80 expect(testSubject()).toBeTruthy();81 });82 });83 });84 describe("when one action is hiding", function() {85 beforeEach(function() {86 oneAction = new DecentStickyAction(function() {}, oneElement, 'hide');87 });88 describe("when the other action is clearing", function() {89 beforeEach(function() {90 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');91 });92 it("doesn't contravene", function() {93 expect(testSubject()).not.toBeTruthy();94 });95 });96 describe("when the other action is hiding", function() {97 beforeEach(function() {98 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');99 });100 it("doesn't contravene", function() {101 expect(testSubject()).not.toBeTruthy();102 });103 });104 describe("when the other action is showing", function() {105 beforeEach(function() {106 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');107 });108 it("contravenes", function() {109 expect(testSubject()).toBeTruthy();110 });111 });112 });113 describe("when one action is showing", function() {114 beforeEach(function() {115 oneAction = new DecentStickyAction(function() {}, oneElement, 'show');116 });117 describe("when the other action is clearing", function() {118 beforeEach(function() {119 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');120 });121 it("contravenes", function() {122 expect(testSubject()).toBeTruthy();123 });124 });125 describe("when the other action is hiding", function() {126 beforeEach(function() {127 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');128 });129 it("contravenes", function() {130 expect(testSubject()).toBeTruthy();131 });132 });133 describe("when the other action is showing", function() {134 beforeEach(function() {135 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');136 });137 it("doesn't contravene", function() {138 expect(testSubject()).not.toBeTruthy();139 });140 });141 });142 });143 describe("when the actions have to do with different elements", function() {144 beforeEach(function() {145 oneElement = affix('#div').get(0);146 anotherElement = affix('#div').get(0);147 });148 describe("when one action is clearing", function() {149 beforeEach(function() {150 oneAction = new DecentStickyAction(function() {}, oneElement, 'clear');151 });152 describe("when the other action is clearing", function() {153 beforeEach(function() {154 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');155 });156 it("doesn't contravene", function() {157 expect(testSubject()).not.toBeTruthy();158 });159 });160 describe("when the other action is hiding", function() {161 beforeEach(function() {162 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');163 });164 it("doesn't contravene", function() {165 expect(testSubject()).not.toBeTruthy();166 });167 });168 describe("when the other action is showing", function() {169 beforeEach(function() {170 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');171 });172 it("doesn't contravene", function() {173 expect(testSubject()).not.toBeTruthy();174 });175 });176 });177 describe("when one action is hiding", function() {178 beforeEach(function() {179 oneAction = new DecentStickyAction(function() {}, oneElement, 'hide');180 });181 describe("when the other action is clearing", function() {182 beforeEach(function() {183 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');184 });185 it("doesn't contravene", function() {186 expect(testSubject()).not.toBeTruthy();187 });188 });189 describe("when the other action is hiding", function() {190 beforeEach(function() {191 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');192 });193 it("doesn't contravene", function() {194 expect(testSubject()).not.toBeTruthy();195 });196 });197 describe("when the other action is showing", function() {198 beforeEach(function() {199 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');200 });201 it("doesn't contravene", function() {202 expect(testSubject()).not.toBeTruthy();203 });204 });205 });206 describe("when one action is showing", function() {207 beforeEach(function() {208 oneAction = new DecentStickyAction(function() {}, oneElement, 'show');209 });210 describe("when the other action is clearing", function() {211 beforeEach(function() {212 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');213 });214 it("doesn't contravene", function() {215 expect(testSubject()).not.toBeTruthy();216 });217 });218 describe("when the other action is hiding", function() {219 beforeEach(function() {220 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');221 });222 it("doesn't contravene", function() {223 expect(testSubject()).not.toBeTruthy();224 });225 });226 describe("when the other action is showing", function() {227 beforeEach(function() {228 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');229 });230 it("doesn't contravene", function() {231 expect(testSubject()).not.toBeTruthy();232 });233 });234 });235 });236 });237 describe("equals: determining when two actions equal each other", function() {238 var oneAction, anotherAction,239 oneElement, anotherElement,240 testSubject = function() {241 return oneAction.equals(anotherAction);242 };243 describe("when the actions have to do with the same element", function() {244 beforeEach(function() {245 oneElement = affix('#div').get(0);246 anotherElement = oneElement;247 });248 describe("when one action is clearing", function() {249 beforeEach(function() {250 oneAction = new DecentStickyAction(function() {}, oneElement, 'clear');251 });252 describe("when the other action is clearing", function() {253 beforeEach(function() {254 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');255 });256 it("equals", function() {257 expect(testSubject).toBeTruthy();258 });259 });260 describe("when the other action is hiding", function() {261 beforeEach(function() {262 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');263 });264 it("doesn't equal", function() {265 expect(testSubject()).not.toBeTruthy();266 });267 });268 describe("when the other action is showing", function() {269 beforeEach(function() {270 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');271 });272 it("doesn't equal", function() {273 expect(testSubject()).not.toBeTruthy();274 });275 });276 });277 describe("when one action is hiding", function() {278 beforeEach(function() {279 oneAction = new DecentStickyAction(function() {}, oneElement, 'hide');280 });281 describe("when the other action is clearing", function() {282 beforeEach(function() {283 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');284 });285 it("doesn't equal", function() {286 expect(testSubject()).not.toBeTruthy();287 });288 });289 describe("when the other action is hiding", function() {290 beforeEach(function() {291 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');292 });293 it("equals", function() {294 expect(testSubject).toBeTruthy();295 });296 });297 describe("when the other action is showing", function() {298 beforeEach(function() {299 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');300 });301 it("doesn't equal", function() {302 expect(testSubject()).not.toBeTruthy();303 });304 });305 });306 describe("when one action is showing", function() {307 beforeEach(function() {308 oneAction = new DecentStickyAction(function() {}, oneElement, 'show');309 });310 describe("when the other action is clearing", function() {311 beforeEach(function() {312 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');313 });314 it("doesn't equal", function() {315 expect(testSubject()).not.toBeTruthy();316 });317 });318 describe("when the other action is hiding", function() {319 beforeEach(function() {320 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');321 });322 it("doesn't equal", function() {323 expect(testSubject()).not.toBeTruthy();324 });325 });326 describe("when the other action is showing", function() {327 beforeEach(function() {328 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');329 });330 it("equals", function() {331 expect(testSubject).toBeTruthy();332 });333 });334 });335 });336 describe("when the actions have to do with different elements", function() {337 beforeEach(function() {338 oneElement = affix('#div').get(0);339 anotherElement = affix('#div').get(0);340 });341 describe("when one action is clearing", function() {342 beforeEach(function() {343 oneAction = new DecentStickyAction(function() {}, oneElement, 'clear');344 });345 describe("when the other action is clearing", function() {346 beforeEach(function() {347 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');348 });349 it("doesn't equal", function() {350 expect(testSubject()).not.toBeTruthy();351 });352 });353 describe("when the other action is hiding", function() {354 beforeEach(function() {355 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');356 });357 it("doesn't equal", function() {358 expect(testSubject()).not.toBeTruthy();359 });360 });361 describe("when the other action is showing", function() {362 beforeEach(function() {363 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');364 });365 it("doesn't equal", function() {366 expect(testSubject()).not.toBeTruthy();367 });368 });369 });370 describe("when one action is hiding", function() {371 beforeEach(function() {372 oneAction = new DecentStickyAction(function() {}, oneElement, 'hide');373 });374 describe("when the other action is clearing", function() {375 beforeEach(function() {376 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');377 });378 it("doesn't equal", function() {379 expect(testSubject()).not.toBeTruthy();380 });381 });382 describe("when the other action is hiding", function() {383 beforeEach(function() {384 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');385 });386 it("doesn't equal", function() {387 expect(testSubject()).not.toBeTruthy();388 });389 });390 describe("when the other action is showing", function() {391 beforeEach(function() {392 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');393 });394 it("doesn't equal", function() {395 expect(testSubject()).not.toBeTruthy();396 });397 });398 });399 describe("when one action is showing", function() {400 beforeEach(function() {401 oneAction = new DecentStickyAction(function() {}, oneElement, 'show');402 });403 describe("when the other action is clearing", function() {404 beforeEach(function() {405 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'clear');406 });407 it("doesn't equal", function() {408 expect(testSubject()).not.toBeTruthy();409 });410 });411 describe("when the other action is hiding", function() {412 beforeEach(function() {413 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'hide');414 });415 it("doesn't equal", function() {416 expect(testSubject()).not.toBeTruthy();417 });418 });419 describe("when the other action is showing", function() {420 beforeEach(function() {421 anotherAction = new DecentStickyAction(function() {}, anotherElement, 'show');422 });423 it("doesn't equal", function() {424 expect(testSubject()).not.toBeTruthy();425 });426 });427 });428 });429 });430});431describe("DecentStickyLocation: Representing the locations of sticky notes.", function() {432 describe("DecentStickyLocation.overlapsWith: Determining whether two locations overlap.", function() {433 var locationA, locationB;434 describe("when the top of A overlaps the bottom of B", function() {435 beforeEach(function() {436 locationA = new DecentStickyLocation(90, 550, 250, 150);437 locationB = new DecentStickyLocation(10, 500, 110, 100);438 });439 it("notes the overlap", function() {440 expect(locationA.overlapsWith(locationB)).toEqual(true);441 expect(locationB.overlapsWith(locationA)).toEqual(true);442 });443 });444 describe("when the bottom of A overlaps the top of B", function() {445 beforeEach(function() {446 locationA = new DecentStickyLocation(10, 500, 110, 100);447 locationB = new DecentStickyLocation(90, 550, 250, 150);448 });449 it("notes the overlap", function() {450 expect(locationA.overlapsWith(locationB)).toEqual(true);451 expect(locationB.overlapsWith(locationA)).toEqual(true);452 });453 });454 describe("when the left of A overlaps the right of B", function() {455 beforeEach(function() {456 locationA = new DecentStickyLocation(150, 500, 550, 150);457 locationB = new DecentStickyLocation(100, 400, 500, 100);458 });459 it("notes the overlap", function() {460 expect(locationA.overlapsWith(locationB)).toEqual(true);461 expect(locationB.overlapsWith(locationA)).toEqual(true);462 });463 });464 describe("when the right of A overlaps the left of B", function() {465 beforeEach(function() {466 locationA = new DecentStickyLocation(100, 400, 500, 100);467 locationB = new DecentStickyLocation(150, 500, 550, 150);468 });469 it("notes the overlap", function() {470 expect(locationA.overlapsWith(locationB)).toEqual(true);471 expect(locationB.overlapsWith(locationA)).toEqual(true);472 });473 });474 describe("when A completely encloses B", function() {475 beforeEach(function() {476 locationA = new DecentStickyLocation(100, 600, 400, 300);477 locationB = new DecentStickyLocation(200, 500, 300, 400);478 });479 it("notes the overlap", function() {480 expect(locationA.overlapsWith(locationB)).toEqual(true);481 expect(locationB.overlapsWith(locationA)).toEqual(true);482 });483 });484 describe("when A completely encloses B vertically, but not horizontally", function() {485 beforeEach(function() {486 locationA = new DecentStickyLocation(100, 600, 400, 300);487 locationB = new DecentStickyLocation(200, 700, 300, 100);488 });489 it("notes the overlap", function() {490 expect(locationA.overlapsWith(locationB)).toEqual(true);491 expect(locationB.overlapsWith(locationA)).toEqual(true);492 });493 });494 describe("when A completely encloses B horizontally, but not vertically", function() {495 beforeEach(function() {496 locationA = new DecentStickyLocation(100, 600, 400, 300);497 locationB = new DecentStickyLocation(50, 500, 500, 400);498 });499 it("notes the overlap", function() {500 expect(locationA.overlapsWith(locationB)).toEqual(true);501 expect(locationB.overlapsWith(locationA)).toEqual(true);502 });503 });504 describe("when A and B exactly overlap", function() {505 beforeEach(function() {506 locationA = new DecentStickyLocation(100, 600, 400, 300);507 locationB = new DecentStickyLocation(100, 600, 400, 300);508 });509 it("notes the overlap", function() {510 expect(locationA.overlapsWith(locationB)).toEqual(true);511 expect(locationB.overlapsWith(locationA)).toEqual(true);512 });513 });514 describe("when the top of A is below the bottom of B", function() {515 beforeEach(function() {516 locationA = new DecentStickyLocation(700, 500, 1200, 100);517 locationB = new DecentStickyLocation(100, 500, 600, 100);518 });519 it("doesn't say there's an overlap", function() {520 expect(locationA.overlapsWith(locationB)).toEqual(false);521 expect(locationB.overlapsWith(locationA)).toEqual(false);522 });523 });524 describe("when the bottom of A is above the top of B", function() {525 beforeEach(function() {526 locationA = new DecentStickyLocation(100, 500, 600, 100);527 locationB = new DecentStickyLocation(700, 500, 1200, 100);528 });529 it("doesn't say there's an overlap", function() {530 expect(locationA.overlapsWith(locationB)).toEqual(false);531 expect(locationB.overlapsWith(locationA)).toEqual(false);532 });533 });534 describe("when the left of A is to the right of B", function() {535 beforeEach(function() {536 locationA = new DecentStickyLocation(100, 1200, 600, 700);537 locationB = new DecentStickyLocation(100, 600, 600, 100);538 });539 it("doesn't say there's an overlap", function() {540 expect(locationA.overlapsWith(locationB)).toEqual(false);541 expect(locationB.overlapsWith(locationA)).toEqual(false);542 });543 });544 describe("when the right of A is to the left of B", function() {545 beforeEach(function() {546 locationA = new DecentStickyLocation(100, 600, 600, 100);547 locationB = new DecentStickyLocation(100, 1200, 600, 700);548 });549 it("doesn't say there's an overlap", function() {550 expect(locationA.overlapsWith(locationB)).toEqual(false);551 expect(locationB.overlapsWith(locationA)).toEqual(false);552 });553 });554 });...

Full Screen

Full Screen

clear_float.js

Source:clear_float.js Github

copy

Full Screen

1/**2 * Copyright 2010 Google Inc.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16/**17 * @fileoverview Check floating layout of not clear floating or18 * clear floating fail or use IE hasLayout.19 * @bug https://code.google.com/p/compatibility-detector/issues/detail?id=15520 * Floating layout is a common layout. IE will calculate the height of the21 * container which is hasLayout. In CSS2.1 only the container which22 * establishes new block formatting context will have this behaviour.23 * And if a have 'clearance' style element appears after the floating elements,24 * there is no difference in all browsers.25 *26 * Detecting steps:27 * 1. Ignore the HTML BODY FORM A elements.28 * 2. Ignore the element who has no descendant floats.29 * 3. Ignore the elements which is hasLayout and establishes new block30 * formatting context.31 * 4. Ignore normal floating layout without ':after' pseudo-elements on which32 * setting 'clear' property, and not hasLayout, and not establishes a block33 * formatting context.34 * 5. Ignore this case: If a element who is not established a block35 * formatting context and its descendant floats are not overflow.36 * 6. Ignore set the element hight layout (this is set hasLayout in IE) of37 * the not use ':after' pseudo-element processing floating Layout, and38 * floating layout is not overflow ancestor element, and element not set39 * new block formatting context.40 * 7. Ignore set pseudo element ':after' clear floating, and triggered41 * IE hasLayout.42 * 8. Check if childer have the floating, and layout is not clear floating,43 * and use pseudo element ':after' clear floating, report the IE6 issue.44 * 9. Check if the element triggered hasLayout in IE or block formatting45 * contexts, if childer have not clear the floating elements.46 * report the IE or other issue.47 * 10.Check if the element display style is 'table-xxxx', if childer have48 * not clear the floating elements, report the IE6/7 issue.49 * 11.Check if the element layout clear floating fail, and set hasLayout50 * in IE or new block formatting context, report the IE or other issue.51 *52 * ps: This detector not detection use CSS hack.53 */54addScriptToInject(function() {55chrome_comp.CompDetect.declareDetector(56'clear_float',57chrome_comp.CompDetect.ScanDomBaseDetector,58function constructor() {59 this.floatNode = null;60 /**61 * Get child nodes float or clear style is not 'none'.62 * @param {Element} node63 * @param {string} styleName is 'float' or 'clear'64 * @return {Array.<Element>} node array65 */66 this.getVisibleChildrenByFloatOrClear = function(node, styleName) {67 var children = Array.prototype.slice.call(node.children);68 var nodes = [];69 for (var i = 0, c = children.length; i < c; ++i) {70 var childNode = children[i];71 var computedStyle = chrome_comp.getComputedStyle(childNode);72 if (styleValue = computedStyle[styleName] != 'none' &&73 computedStyle.display != 'none' &&74 childNode.offsetHeight > 0)75 nodes.push(childNode);76 }77 return nodes;78 };79 /**80 * Check subsequent element clear floating of the node.81 *82 * A.83 * +--------------------------------------------+84 * | +-------------------------------+ |85 * | | float node | |86 * | +-------------------------------+ |87 * | +--------------------------------------+ |88 * | | clear node | |89 * | +--------------------------------------+ |90 * +--------------------------------------------+91 * +--------------------------------------------+92 * | other layout block |93 * +--------------------------------------------+94 *95 * B.96 * +--------------------------------------------+97 * | +-------------------------------+ |98 * +--| float node |---------+99 * +-------------------------------+100 * +--------------------------------------------+101 * | clear node |102 * +--------------------------------------------+103 * +--------------------------------------------+104 * | other layout block |105 * +--------------------------------------------+106 *107 * C.108 * +--------------------------------------------+109 * | +-------------------------------------+ |110 * | | +-------------------------------+ | |111 * | +--| float node |--+ |112 * +-----| |----- +113 * +-------------------------------+114 * +--------------------------------------------+115 * | clear node |116 * +--------------------------------------------+117 * +--------------------------------------------+118 * | other layout block |119 * +--------------------------------------------+120 *121 * D.122 * +--------------------------------------------+123 * | +-------------------------------------+ |124 * | | +-------------------------------+ | |125 * | +--| float node |--+ |126 * | | | |127 * | +-------------------------------+ |128 * | +--------------------------------------+ |129 * | | clear node | |130 * | +--------------------------------------+ |131 * +--------------------------------------------+132 * +--------------------------------------------+133 * | other layout block |134 * +--------------------------------------------+135 */136 this.isNextElementClear = function(node) {137 var nextSibling = this.getNextAffectFloatingLayoutElementByNode(node);138 var parentNextSibling =139 this.getNextAffectFloatingLayoutElementByParentNode(node);140 if (nextSibling)141 return this.hasClearStyle(nextSibling);142 // The layout has no problem if it's the last node of DOM tree.143 if (!nextSibling && !parentNextSibling)144 return true;145 // The next slibling clear success of parent elment.146 if (!this.hasClearStyle(parentNextSibling))147 return false;148 return false;149 };150 this.hasClearStyle = function(node) {151 return (chrome_comp.getComputedStyle(node).clear != 'none');152 };153 /**154 * Check parent node of the node, if it is visual non-inline elment155 * of normal flow.156 * @param {Node} node157 * @return {Node} It is null or it is noraml flow or floats node.158 * If node is BODY return is null.159 */160 this.getNextAffectFloatingLayoutElementByParentNode = function(node) {161 // The last element of the document and no impact is not clear float.162 if (!node || node.tagName == 'BODY' || node.tagName == 'HTML')163 return null;164 node = node.parentNode;165 var nextSibling = this.getNextAffectFloatingLayoutElementByNode(node);166 if (!nextSibling)167 return this.getNextAffectFloatingLayoutElementByParentNode(node);168 else169 return nextSibling;170 };171 /**172 * Get the next sibling element which is visible, non-inline and in normal173 * flow.174 * @param {Element} node175 * @return {Element} null if not found176 */177 this.getNextAffectFloatingLayoutElementByNode = function(node) {178 node = node.nextSibling;179 for (; node; node = node.nextSibling) {180 if (Node.ELEMENT_NODE != node.nodeType)181 continue;182 var style = chrome_comp.getComputedStyle(node);183 if (style.display != 'none' &&184 style.display.indexOf('inline') != 0 &&185 (node.childElementCount == 0 ||186 this.isAffectedByChildrenLayout(node)))187 return node;188 }189 return null;190 };191 /**192 * Check childer element, if it is in normal flow or floats return true,193 * else return false.194 */195 this.isAffectedByChildrenLayout = function(node) {196 var children = Array.prototype.slice.call(node.children);197 for (var i = 0, c = children.length; i < c; ++i) {198 var computedStyle = chrome_comp.getComputedStyle(children[i]);199 if (!(computedStyle.display == 'none' ||200 computedStyle.position == 'absolute' ||201 computedStyle.position == 'fixed'))202 return true;203 }204 return false;205 };206 this.isPseudoElementClear = function(node) {207 // Temporary use window.getComputedStyle method,208 // wait framework.js fixed, replace the window.getComputedStyle method209 // to the chrome_comp.getComputedStyle method.210 var pseudoStyle = window.getComputedStyle(node,':after');211 // Triggered ie hasLayout features and use ':after' pseudo-element212 // processing floating Layout, not detection.213 return pseudoStyle.display == 'block' && pseudoStyle.clear != 'none';214 }215 this.isClearSuccess = function(floatNodes, clearNodes) {216 if (clearNodes == 0)217 return false;218 var lastFloatNode = floatNodes[floatNodes.length - 1];219 var lastClearNode = clearNodes[clearNodes.length - 1];220 // Used to compareDocumentPosition method compare two elements221 // of position, if the A element in the B element after, return 2.222 if (lastClearNode.compareDocumentPosition(lastFloatNode) != 2) {223 this.floatNode = lastFloatNode;224 return false;225 }226 return true;227 };228 this.isFloatsOverflowContainer = function(floatNodes, container) {229 var containerBottom = container.getBoundingClientRect().bottom +230 parseInt(chrome_comp.getComputedStyle(container).marginBottom, 10);231 for (var i = 0, c = floatNodes.length; i < c; ++i) {232 var floatNodeBottom = floatNodes[i].getBoundingClientRect().bottom;233 if (containerBottom < floatNodeBottom) {234 this.floatNode = floatNodes[i];235 return true;236 }237 }238 return false;239 };240 this.hasBackground = function(nodeStyle) {241 return (nodeStyle.backgroundImage != 'none' ||242 nodeStyle.backgroundColor != 'rgba(0, 0, 0, 0)');243 };244 this.hasBorder = function(nodeStyle) {245 return (parseInt(nodeStyle.borderTopWidth, 10) > 0 ||246 parseInt(nodeStyle.borderRightWidth, 10) > 0 ||247 parseInt(nodeStyle.borderBottomWidth, 10) > 0 ||248 parseInt(nodeStyle.borderLeftWidth, 10) > 0);249 };250 this.setProblem = function(node) {251 this.addProblem('RM8002', {252 nodes: [node, this.floatNode],253 details: 'Problem Element height is ' +254 chrome_comp.getComputedStyle(node).height255 });256 };257},258function checkNode(node, context) {259 if (Node.ELEMENT_NODE != node.nodeType || context.isDisplayNone())260 return;261 var IGNORED_TAGS = {HTML: true, BODY: true, FORM: true};262 if (node.tagName in IGNORED_TAGS)263 return;264 var computedStyle = chrome_comp.getComputedStyle(node);265 if (computedStyle.display == 'inline')266 return;267 var floatNodes = this.getVisibleChildrenByFloatOrClear(node, 'float');268 // Stop detection if it has no descendant floats.269 if (floatNodes.length == 0)270 return;271 var hasLayout = chrome_comp.hasLayoutInIE(node);272 var hasBFC = chrome_comp.isBlockFormattingContext(node);273 // Stop detection if it hasLayout in IE and established274 // a BFC in other browsers.275 if (hasLayout && hasBFC)276 return;277 var hasBorder = this.hasBorder(computedStyle);278 var hasBackground = this.hasBackground(computedStyle);279 if (this.isNextElementClear(node) && !hasBorder && !hasBackground)280 return;281 var isPseudoElementClear = this.isPseudoElementClear(node);282 var isOverflow = this.isFloatsOverflowContainer(floatNodes, node);283 var clearNodes = this.getVisibleChildrenByFloatOrClear(node, 'clear');284 var clearNodeCount = clearNodes.length;285 // Stop detection if it's not established a BFC and its descendant286 // floats are not overflow.287 if (!isOverflow && !isPseudoElementClear && !hasBFC)288 return;289 // Normal float layout is not detection.290 if (clearNodeCount == 0 && !isPseudoElementClear &&291 !hasLayout && !hasBFC &&292 !hasBorder && !hasBackground)293 return;294 // Node is set hasLayout in IE, sub-element is float layout and not overfolw295 // ancestor element, not detection.296 // ps: set height triggered hasLayout in IE.297 if (clearNodeCount == 0 && !isPseudoElementClear && !isOverflow && !hasBFC)298 return;299 // Use pseudo element ':after' clear floating, and triggered IE hasLayout,300 // not detection.301 if (clearNodeCount == 0 && isPseudoElementClear && hasLayout)302 return;303 // Only use pseudo element ':after' clear floating.304 if (clearNodeCount == 0 && isPseudoElementClear && !hasLayout) {305 this.addProblem('RS8010', {306 nodes: [node],307 details: 'Problem Element set ":after" pseudo element.'308 });309 }310 // Detection the element triggered hasLayout in IE or Block Formatting311 // Contexts, if childer have not clear the floating elements.312 // report the issue.313 if (clearNodeCount == 0 && (hasLayout || hasBFC)) {314 this.floatNode = floatNodes[0];315 this.setProblem(node);316 return;317 }318 // Detection the element display style is 'table-xxxx',319 // if childer have not clear the floating elements.320 // report the issue.321 if (clearNodeCount == 0 &&322 computedStyle.display.indexOf('table') == 0) {323 this.floatNode = floatNodes[0];324 this.setProblem(node);325 return;326 }327 // Detection sub-elements clear floating fail, and triggered hasLayout328 // in IE or Block Formatting Contexts, report the issue.329 if (!this.isClearSuccess(floatNodes, clearNodes) &&330 !(!isOverflow && hasLayout && hasBFC) && !isPseudoElementClear) {331 this.setProblem(node);332 return;333 }334}335); // declareDetector...

Full Screen

Full Screen

my-practice-question.spec.js

Source:my-practice-question.spec.js Github

copy

Full Screen

1context('My Practice Questions', () => {2 //all tests have just one question3 beforeEach(() => {4 cy.setRole('student')5 });6 it('should show empty message', () => {7 cy.visit('/course/3/practice-questions')8 cy.disableTours();9 cy.get('.empty-practice-questions-content .empty-practice-questions-header')10 .should('have.text', 'No questions have been saved for practice.');11 cy.getTestElement('save-practice-button').should('be.disabled');12 cy.getTestElement('save-practice-button')13 .should('have.text', 'Save to practice');14 })15 it('should list a question that is not available', () => {16 cy.visit('/course/2/practice-questions')17 cy.disableTours();18 cy.getTestElement('clear-practice-selection').should('exist');19 cy.getTestElement('start-practice').should('exist');20 cy.getTestElement('clear-practice-selection').should('be.disabled');21 cy.getTestElement('start-practice').should('be.disabled');22 cy.get('.card-body').should('exist');23 cy.get('.card-body').click({ force: true });24 cy.get('.card-body .disabled-message').should('be.visible');25 cy.get('.card-body .disabled-message').should('have.text', 26 'This question can be practiced after it has been graded');27 })28 it('should list a question that is available, include and exclude the question', () => {29 cy.visit('/course/1/practice-questions')30 cy.disableTours();31 cy.getTestElement('clear-practice-selection').should('exist');32 cy.getTestElement('start-practice').should('exist');33 cy.getTestElement('clear-practice-selection').should('be.disabled');34 cy.getTestElement('start-practice').should('be.disabled');35 cy.get('.card-body').should('exist');36 cy.get('.card-body .controls-overlay').should('exist');37 //when user includes a question38 cy.get('.action.include').click({ force: true });39 cy.get('.selected-mask').should('exist');40 cy.getTestElement('clear-practice-selection').should('be.enabled');41 cy.getTestElement('start-practice').should('be.enabled');42 //when user excludes the question43 cy.get('.action.exclude').click({ force: true });44 cy.get('.selected-mask').should('not.exist');45 cy.getTestElement('clear-practice-selection').should('be.disabled');46 cy.getTestElement('start-practice').should('be.disabled');47 //when user includes a question and clicks on 'clear selection' button48 cy.get('.action.include').click({ force: true });49 cy.getTestElement('clear-practice-selection').click();50 cy.get('.selected-mask').should('not.exist');51 cy.getTestElement('clear-practice-selection').should('be.disabled');52 cy.getTestElement('start-practice').should('be.disabled');53 })54 it('should list a question that is available and delete the question', () => {55 cy.visit('/course/1/practice-questions')56 cy.disableTours();57 cy.get('.delete').click({ force: true });58 cy.getTestElement('confirm-delete-practice-question').click();59 cy.get('.empty-practice-questions-content .empty-practice-questions-header')60 .should('have.text', 'No questions have been saved for practice.');61 })...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1function recursiveAnimationFrame(frames, callback) {2 if (window && frames && Number.isInteger(frames) && frames > 0) {3 window.requestAnimationFrame(() => {4 recursiveAnimationFrame(frames - 1, callback);5 });6 return;7 }8 callback();9}10export function setCssEndEvent(11 element,12 type,13 { tolerance = 0, propertyName } = {}14) {15 return new Promise(resolve => {16 if (!element) {17 resolve(false);18 return;19 }20 let eventName = null;21 const capitalized = type.charAt(0).toUpperCase() + type.slice(1);22 let run = 0;23 function end(event) {24 const target = event.srcElement || event.target;25 if (target === element) {26 if (run >= tolerance) {27 if (propertyName && propertyName !== event.propertyName) {28 return;29 }30 element.removeEventListener(eventName, end);31 resolve(event);32 }33 run += 1;34 }35 }36 if (element.style[`Webkit${capitalized}`] !== undefined) {37 eventName = `webkit${capitalized}End`;38 }39 if (element.style.OTransition !== undefined) {40 eventName = `o${type}End`;41 }42 if (element.style[type] !== undefined) {43 eventName = `${type}end`;44 }45 if (element.clearCssEndEvent) {46 element.clearCssEndEvent();47 }48 element.clearCssEndEvent = function() {49 element.removeEventListener(eventName, end);50 };51 element.addEventListener(eventName, end);52 });53}54export function beforeCssLayout(callback) {55 window && window.requestAnimationFrame(callback);56}57export function beforeNextCssLayout(callback) {58 window &&59 window.requestAnimationFrame(() => {60 window.requestAnimationFrame(callback);61 });62}63export function beforeFutureCssLayout(frames, callback) {64 recursiveAnimationFrame(frames + 1, callback);65}66export function onceNextCssLayout() {67 return new Promise(resolve => {68 beforeNextCssLayout(resolve);69 });70}71export function onceTransitionEnd(element, options = {}) {72 return new Promise(resolve => {73 setCssEndEvent(element, "transition", options).then(resolve);74 });75}76export function onceAnimationEnd(element, options = {}) {77 return new Promise(resolve => {78 setCssEndEvent(element, "animation", options).then(resolve);79 });...

Full Screen

Full Screen

ngTransclude_test.js

Source:ngTransclude_test.js Github

copy

Full Screen

1describe("api/ng.directive:ngTransclude", function() {2 describe("angular+jqLite", function() {3 beforeEach(function() {4 browser.get("index-nocache.html#!/api/ng.directive:ngTransclude");5 });6 it('should have transcluded', function() {7 var titleElement = element(by.model('title'));8 titleElement.clear();9 titleElement.sendKeys('TITLE');10 var textElement = element(by.model('text'));11 textElement.clear();12 textElement.sendKeys('TEXT');13 expect(element(by.binding('title')).getText()).toEqual('TITLE');14 expect(element(by.binding('text')).getText()).toEqual('TEXT');15 });16 });17 describe("angular+jQuery", function() {18 beforeEach(function() {19 browser.get("index-jq-nocache.html#!/api/ng.directive:ngTransclude");20 });21 it('should have transcluded', function() {22 var titleElement = element(by.model('title'));23 titleElement.clear();24 titleElement.sendKeys('TITLE');25 var textElement = element(by.model('text'));26 textElement.clear();27 textElement.sendKeys('TEXT');28 expect(element(by.binding('title')).getText()).toEqual('TITLE');29 expect(element(by.binding('text')).getText()).toEqual('TEXT');30 });31 });...

Full Screen

Full Screen

TimeSpent.js

Source:TimeSpent.js Github

copy

Full Screen

1import { h } from 'hyperapp';2import { timeSpetnToString } from '../utils';3const timer = (element, time) => {4 let last = Date.now();5 let $interval = setInterval(() => {6 let now = Date.now();7 time += now - last;8 last = now;9 element.textContent = timeSpetnToString(time);10 }, 1000);11 element.$clearInterval = () => clearInterval($interval);12};13const TimeSpent = ({ timeSpent, active }) => {14 let clear = element => element.$clearInterval && element.$clearInterval();15 return (16 <span17 oncreate={element => {18 clear(element);19 if (active) timer(element, timeSpent);20 }}21 onupdate={element => {22 clear(element);23 if (active) {24 timer(element, timeSpent);25 }26 }}27 onremove={clear}28 >29 {timeSpetnToString(timeSpent)}30 </span>31 );32};...

Full Screen

Full Screen

jquery_test.js

Source:jquery_test.js Github

copy

Full Screen

1describe("module:ng.directive:ngTransclude", function() {2 var rootEl;3 beforeEach(function() {4 rootEl = browser.rootEl;5 browser.get("./examples/example-example46/index-jquery.html");6 });7 8 it('should have transcluded', function() {9 var titleElement = element(by.model('title'));10 titleElement.clear();11 titleElement.sendKeys('TITLE');12 var textElement = element(by.model('text'));13 textElement.clear();14 textElement.sendKeys('TEXT');15 expect(element(by.binding('title')).getText()).toEqual('TITLE');16 expect(element(by.binding('text')).getText()).toEqual('TEXT');17 });...

Full Screen

Full Screen

protractor.js

Source:protractor.js Github

copy

Full Screen

1it('should have transcluded', function() {2 var titleElement = element(by.model('title'));3 titleElement.clear();4 titleElement.sendKeys('TITLE');5 var textElement = element(by.model('text'));6 textElement.clear();7 textElement.sendKeys('TEXT');8 expect(element(by.binding('title')).getText()).toEqual('TITLE');9 expect(element(by.binding('text')).getText()).toEqual('TEXT');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 until = webdriver.until;3var driver = new webdriver.Builder()4 .forBrowser('firefox')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnG')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9driver.quit();10driver.findElement(By.name('q')).sendKeys('webdriver');11driver.findElement(By.name('btnG')).click();12driver.wait(until.titleIs('webdriver - Google Search'), 1000);13driver.findElement(By.name('q')).clear();14driver.quit();15driver.findElement(By.name('q')).sendKeys('webdriver');16driver.findElement(By.name('btnG')).click();17driver.wait(until.titleIs('webdriver - Google Search'), 1000);18driver.findElement(By.name('q')).sendKeys('webdriver');19driver.quit();20driver.findElement(By.name('q')).sendKeys('webdriver');21driver.findElement(By.name('btnG')).click();22driver.wait(until.titleIs('webdriver - Google Search'), 1000);23driver.findElement(By.name('q')).sendKeys('webdriver');24driver.findElement(By.name('q')).clear();25driver.quit();26driver.findElement(By.name('q')).sendKeys('webdriver');27driver.findElement(By.name('btnG')).click();28driver.wait(until.titleIs('webdriver - Google Search'), 1000);29driver.findElement(By.name('q')).sendKeys('webdriver');30driver.findElement(By.name('q')).clear();31driver.findElement(By.name('q')).sendKeys('webdriver');32driver.quit();33driver.findElement(By.name('q')).sendKeys('webdriver');34driver.findElement(By.name('btnG')).click();35driver.wait(until.titleIs('webdriver - Google Search'), 1000);36driver.findElement(By.name('q')).sendKeys('webdriver');37driver.findElement(By.name('q')).clear();38driver.findElement(By.name

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 until = webdriver.until;3var driver = new webdriver.Builder()4 .forBrowser('chrome')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnK')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9driver.findElement(By.name('q')).clear();10driver.findElement(By.name('q')).sendKeys('appium');11driver.findElement(By.name('btnK')).click();12driver.wait(until.titleIs('appium - Google Search'), 1000);13driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var By = webdriver.By;3var until = webdriver.until;4var driver = new webdriver.Builder()5 .forBrowser('chrome')6 .build();7driver.findElement(By.name('q')).sendKeys('webdriver');8driver.findElement(By.name('btnK')).click();9driver.wait(until.titleIs('webdriver - Google Search'), 1000);10driver.quit();11var webdriver = require('selenium-webdriver');12var By = webdriver.By;13var until = webdriver.until;14var driver = new webdriver.Builder()15 .forBrowser('chrome')16 .build();17driver.findElement(By.name('q')).sendKeys('webdriver');18driver.findElement(By.name('btnK')).click();19driver.wait(until.titleIs('webdriver - Google Search'), 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22var By = webdriver.By;23var until = webdriver.until;24var driver = new webdriver.Builder()25 .forBrowser('chrome')26 .build();27driver.findElement(By.name('q')).sendKeys('webdriver');28driver.findElement(By.name('btnK')).click();29driver.wait(until.titleIs('webdriver - Google Search'), 1000);30driver.quit();31var webdriver = require('selenium-webdriver');32var By = webdriver.By;33var until = webdriver.until;34var driver = new webdriver.Builder()35 .forBrowser('chrome')36 .build();37driver.findElement(By.name('q')).sendKeys('webdriver');38driver.findElement(By.name('btnK')).click();39driver.wait(until.titleIs('webdriver - Google Search'), 1000);40driver.quit();41var webdriver = require('selenium-webdriver');42var By = webdriver.By;43var until = webdriver.until;44var driver = new webdriver.Builder()45 .forBrowser('chrome')46 .build();47driver.findElement(By.name('q')).sendKeys('webdriver');48driver.findElement(By.name('btnK')).click();49driver.wait(until.titleIs('webdriver - Google Search'), 100

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.findElement(webdriver.By.name('q')).clear();11driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');12driver.findElement(webdriver.By.name('btnG')).click();13driver.wait(function() {14 return driver.getTitle().then(function(title) {15 return title === 'webdriver - Google Search';16 });17}, 1000);18driver.quit();19Appium clear() Method Example in Java20import org.openqa.selenium.By;21import org.openqa.selenium.WebDriver;22import org.openqa.selenium.WebElement;23import org.openqa.selenium.chrome.ChromeDriver;24import org.openqa.selenium.support.ui.ExpectedConditions;25import org.openqa.selenium.support.ui.WebDriverWait;26public class AppiumClearMethod {27public static void main(String[] args) {28 System.setProperty("webdriver.chrome.driver", "C:\\Users\\selenium\\chromedriver.exe");29 WebDriver driver = new ChromeDriver();30 WebElement searchBox = driver.findElement(By.name("q"));31 searchBox.sendKeys("Appium");32 searchBox.clear();33 searchBox.sendKeys("Selenium");34 driver.quit();35}36}37Appium clear() Method Example in Python38from selenium import webdriver39from selenium.webdriver.common.by import By40from selenium.webdriver.support.ui import WebDriverWait41from selenium.webdriver.support import expected_conditions as EC42driver = webdriver.Chrome()43searchBox = driver.find_element_by_name("q")44searchBox.send_keys("Appium")45searchBox.clear()46searchBox.send_keys("Selenium")47driver.quit()48Appium clear() Method Example in Ruby49Appium clear() Method Example in C#

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 Appium 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