How to use field.setValue method in Appium

Best JavaScript code snippet using appium

field_number_test.js

Source:field_number_test.js Github

copy

Full Screen

1/**2 * @license3 * Copyright 2019 Google LLC4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 *   http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17suite('Number Fields', function() {18  function assertValue(numberField, expectedValue, opt_expectedText) {19    var actualValue = numberField.getValue();20    var actualText = numberField.getText();21    opt_expectedText = opt_expectedText || String(expectedValue);22    assertEquals(String(actualValue), String(expectedValue));23    assertEquals(Number(actualValue), expectedValue);24    assertEquals(actualText, opt_expectedText);25  }26  function assertValueDefault(numberField) {27    assertValue(numberField, 0);28  }29  function assertNumberField(numberField, expectedMin, expectedMax,30      expectedPrecision, expectedValue) {31    assertValue(numberField, expectedValue);32    chai.assert.equal(numberField.getMin(), expectedMin);33    chai.assert.equal(numberField.getMax(), expectedMax);34    chai.assert.equal(numberField.getPrecision(), expectedPrecision);35  }36  function assertNumberFieldDefault(numberField) {37    assertNumberField(numberField, -Infinity, Infinity, 0, 0);38  }39  function createNumberFieldSameValuesConstructor(value) {40    return new Blockly.FieldNumber(value, value, value, value);41  }42  function createNumberFieldSameValuesJson(value) {43    return Blockly.FieldNumber.fromJson(44        { 'value': value, min: value, max: value, precision: value });45  }46  function assertNumberFieldSameValues(numberField, value) {47    assertNumberField(numberField, value, value, value, value);48  }49  suite('Constructor', function() {50    test('Empty', function() {51      var numberField = new Blockly.FieldNumber();52      assertNumberFieldDefault(numberField);53    });54    test('Undefined', function() {55      var numberField = createNumberFieldSameValuesConstructor(undefined);56      assertNumberFieldDefault(numberField);57    });58    test('NaN', function() {59      var numberField = createNumberFieldSameValuesConstructor(NaN);60      assertNumberFieldDefault(numberField);61    });62    test('Integer', function() {63      var numberField = createNumberFieldSameValuesConstructor(1);64      assertNumberFieldSameValues(numberField, 1);65    });66    test('Float', function() {67      var numberField = createNumberFieldSameValuesConstructor(1.5);68      assertNumberFieldSameValues(numberField, 1.5);69    });70    test('Integer String', function() {71      var numberField = createNumberFieldSameValuesConstructor('1');72      assertNumberFieldSameValues(numberField, 1);73    });74    test('Float String', function() {75      var numberField = createNumberFieldSameValuesConstructor('1.5');76      assertNumberFieldSameValues(numberField, 1.5);77    });78    test('Infinity', function() {79      var numberField = createNumberFieldSameValuesConstructor('Infinity');80      assertNumberFieldSameValues(numberField, Infinity);81    });82    test('Negative Infinity String', function() {83      var numberField = createNumberFieldSameValuesConstructor('-Infinity');84      assertNumberFieldSameValues(numberField, -Infinity);85    });86  });87  suite('fromJson', function() {88    test('Empty', function() {89      var numberField = Blockly.FieldNumber.fromJson({});90      assertNumberFieldDefault(numberField);91    });92    test('Undefined', function() {93      var numberField = createNumberFieldSameValuesJson(undefined);94      assertNumberFieldDefault(numberField);95    });96    test('NaN', function() {97      var numberField = createNumberFieldSameValuesJson(NaN);98      assertNumberFieldDefault(numberField);99    });100    test('Integer', function() {101      var numberField = createNumberFieldSameValuesJson(1);102      assertNumberFieldSameValues(numberField, 1);103    });104    test('Float', function() {105      var numberField = createNumberFieldSameValuesJson(1.5);106      assertNumberFieldSameValues(numberField, 1.5);107    });108    test('Integer String', function() {109      var numberField = createNumberFieldSameValuesJson('1');110      assertNumberFieldSameValues(numberField, 1);111    });112    test('Float String', function() {113      var numberField = createNumberFieldSameValuesJson('1.5');114      assertNumberFieldSameValues(numberField, 1.5);115    });116    test('Infinity', function() {117      var numberField = createNumberFieldSameValuesJson('Infinity');118      assertNumberFieldSameValues(numberField, Infinity);119    });120    test('Negative Infinity String', function() {121      var numberField = createNumberFieldSameValuesJson('-Infinity');122      assertNumberFieldSameValues(numberField, -Infinity);123    });124  });125  suite('setValue', function() {126    suite('Value Types', function() {127      suite('Empty -> New Value', function() {128        setup(function() {129          this.numberField = new Blockly.FieldNumber();130        });131        test('Null', function() {132          this.numberField.setValue(null);133          assertValueDefault(this.numberField);134        });135        test('Undefined', function() {136          this.numberField.setValue(undefined);137          assertValueDefault(this.numberField);138        });139        test('Non-Parsable String', function() {140          this.numberField.setValue('bad');141          assertValueDefault(this.numberField);142        });143        test('NaN', function() {144          this.numberField.setValue(NaN);145          assertValueDefault(this.numberField);146        });147        test('Integer', function() {148          this.numberField.setValue(2);149          assertValue(this.numberField, 2);150        });151        test('Float', function() {152          this.numberField.setValue(2.5);153          assertValue(this.numberField, 2.5);154        });155        test('Integer String', function() {156          this.numberField.setValue('2');157          assertValue(this.numberField, 2);158        });159        test('Float String', function() {160          this.numberField.setValue('2.5');161          assertValue(this.numberField, 2.5);162        });163        test('Infinity', function() {164          this.numberField.setValue(Infinity);165          assertValue(this.numberField, Infinity);166        });167        test('Negative Infinity String', function() {168          this.numberField.setValue('-Infinity');169          assertValue(this.numberField, -Infinity);170        });171      });172      suite('Value -> New Value', function() {173        setup(function() {174          this.numberField = new Blockly.FieldNumber(1);175        });176        test('Null', function() {177          this.numberField.setValue(null);178          assertValue(this.numberField, 1);179        });180        test('Undefined', function() {181          this.numberField.setValue(undefined);182          assertValue(this.numberField, 1);183        });184        test('Non-Parsable String', function() {185          this.numberField.setValue('bad');186          assertValue(this.numberField, 1);187        });188        test('NaN', function() {189          this.numberField.setValue(NaN);190          assertValue(this.numberField, 1);191        });192        test('Integer', function() {193          this.numberField.setValue(2);194          assertValue(this.numberField, 2);195        });196        test('Float', function() {197          this.numberField.setValue(2.5);198          assertValue(this.numberField, 2.5);199        });200        test('Integer String', function() {201          this.numberField.setValue('2');202          assertValue(this.numberField, 2);203        });204        test('Float String', function() {205          this.numberField.setValue('2.5');206          assertValue(this.numberField, 2.5);207        });208        test('Infinity', function() {209          this.numberField.setValue(Infinity);210          assertValue(this.numberField, Infinity);211        });212        test('Negative Infinity String', function() {213          this.numberField.setValue('-Infinity');214          assertValue(this.numberField, -Infinity);215        });216      });217    });218    suite('Constraints', function() {219      suite('Precision', function() {220        test('Float', function() {221          var numberField = new Blockly.FieldNumber();222          numberField.setValue(123.456);223          assertValue(numberField, 123.456);224        });225        test('0.01', function() {226          var numberField = new Blockly.FieldNumber227              .fromJson({ precision: .01 });228          numberField.setValue(123.456);229          assertValue(numberField, 123.46);230        });231        test('0.5', function() {232          var numberField = new Blockly.FieldNumber233              .fromJson({ precision: .5 });234          numberField.setValue(123.456);235          assertValue(numberField, 123.5);236        });237        test('1', function() {238          var numberField = new Blockly.FieldNumber239              .fromJson({ precision: 1 });240          numberField.setValue(123.456);241          assertValue(numberField, 123);242        });243        test('1.5', function() {244          var numberField = new Blockly.FieldNumber245              .fromJson({ precision: 1.5 });246          numberField.setValue(123.456);247          assertValue(numberField, 123);248        });249        test('Null', function() {250          var numberField = new Blockly.FieldNumber251              .fromJson({ precision: null});252          assertEquals(numberField.getPrecision(), 0);253        });254      });255      suite('Min', function() {256        test('-10', function() {257          var numberField = new Blockly.FieldNumber.fromJson({ min: -10 });258          numberField.setValue(-20);259          assertValue(numberField, -10);260          numberField.setValue(0);261          assertValue(numberField, 0);262          numberField.setValue(20);263          assertValue(numberField, 20);264        });265        test('0', function() {266          var numberField = new Blockly.FieldNumber.fromJson({ min: 0 });267          numberField.setValue(-20);268          assertValue(numberField, 0);269          numberField.setValue(0);270          assertValue(numberField, 0);271          numberField.setValue(20);272          assertValue(numberField, 20);273        });274        test('+10', function() {275          var numberField = new Blockly.FieldNumber.fromJson({ min: 10 });276          numberField.setValue(-20);277          assertValue(numberField, 10);278          numberField.setValue(0);279          assertValue(numberField, 10);280          numberField.setValue(20);281          assertValue(numberField, 20);282        });283        test('Null', function() {284          var numberField = new Blockly.FieldNumber285              .fromJson({ min: null});286          assertEquals(numberField.getMin(), -Infinity);287        });288      });289      suite('Max', function() {290        test('-10', function() {291          var numberField = new Blockly.FieldNumber.fromJson({ max: -10 });292          numberField.setValue(-20);293          assertValue(numberField, -20);294          numberField.setValue(0);295          assertValue(numberField, -10);296          numberField.setValue(20);297          assertValue(numberField, -10);298        });299        test('0', function() {300          var numberField = new Blockly.FieldNumber.fromJson({ max: 0 });301          numberField.setValue(-20);302          assertValue(numberField, -20);303          numberField.setValue(0);304          assertValue(numberField, 0);305          numberField.setValue(20);306          assertValue(numberField, 0);307        });308        test('+10', function() {309          var numberField = new Blockly.FieldNumber.fromJson({ max: 10 });310          numberField.setValue(-20);311          assertValue(numberField, -20);312          numberField.setValue(0);313          assertValue(numberField, 0);314          numberField.setValue(20);315          assertValue(numberField, 10);316        });317        test('null', function() {318          var numberField = new Blockly.FieldNumber319              .fromJson({ max: null});320          assertEquals(numberField.getMax(), Infinity);321        });322      });323    });324  });325  suite('Validators', function() {326    setup(function() {327      this.numberField = new Blockly.FieldNumber(1);328      this.numberField.htmlInput_ = Object.create(null);329      this.numberField.htmlInput_.oldValue_ = '1';330      this.numberField.htmlInput_.untypedDefaultValue_ = 1;331      this.stub = sinon.stub(this.numberField, 'resizeEditor_');332    });333    teardown(function() {334      this.numberField.setValidator(null);335      this.numberField.htmlInput_ = null;336      if (this.stub) {337        this.stub.restore();338      }339    });340    suite('Null Validator', function() {341      setup(function() {342        this.numberField.setValidator(function() {343          return null;344        });345      });346      test('When Editing', function() {347        this.numberField.isBeingEdited_ = true;348        this.numberField.htmlInput_.value = '2';349        this.numberField.onHtmlInputChange_(null);350        assertValue(this.numberField, 1, '2');351        this.numberField.isBeingEdited_ = false;352      });353      test('When Not Editing', function() {354        this.numberField.setValue(2);355        assertValue(this.numberField, 1);356      });357    });358    suite('Force End with 6 Validator', function() {359      setup(function() {360        this.numberField.setValidator(function(newValue) {361          return String(newValue).replace(/.$/, "6");362        });363      });364      test('When Editing', function() {365        this.numberField.isBeingEdited_ = true;366        this.numberField.htmlInput_.value = '25';367        this.numberField.onHtmlInputChange_(null);368        assertValue(this.numberField, 26, '25');369        this.numberField.isBeingEdited_ = false;370      });371      test('When Not Editing', function() {372        this.numberField.setValue(25);373        assertValue(this.numberField, 26);374      });375    });376    suite('Returns Undefined Validator', function() {377      setup(function() {378        this.numberField.setValidator(function() {});379      });380      test('When Editing', function() {381        this.numberField.isBeingEdited_ = true;382        this.numberField.htmlInput_.value = '2';383        this.numberField.onHtmlInputChange_(null);384        assertValue(this.numberField, 2);385        this.numberField.isBeingEdited_ = false;386      });387      test('When Not Editing', function() {388        this.numberField.setValue(2);389        assertValue(this.numberField, 2);390      });391    });392  });393  suite('Customizations', function() {394    suite('Min', function() {395      test('JS Constructor', function() {396        var field = new Blockly.FieldNumber(0, -10);397        assertNumberField(field, -10, Infinity, 0, 0);398      });399      test('JSON Definition', function() {400        var field = Blockly.FieldNumber.fromJson({401          min: -10,402        });403        assertNumberField(field, -10, Infinity, 0, 0);404      });405      test('Set Constraints', function() {406        var field = new Blockly.FieldNumber();407        field.setConstraints(-10);408        assertNumberField(field, -10, Infinity, 0, 0);409      });410      test('Set Min', function() {411        var field = new Blockly.FieldNumber();412        field.setMin(-10);413        assertNumberField(field, -10, Infinity, 0, 0);414      });415      test('JS Configuration - Simple', function() {416        var field = new Blockly.FieldNumber(417            undefined, undefined, undefined, undefined, undefined, {418              min: -10419            });420        assertNumberField(field, -10, Infinity, 0, 0);421      });422      test('JS Configuration - Ignore', function() {423        var field = new Blockly.FieldNumber(424            undefined, -1, undefined, undefined, undefined, {425              min: -10426            });427        assertNumberField(field, -10, Infinity, 0, 0);428      });429    });430    suite('Max', function() {431      test('JS Constructor', function() {432        var field = new Blockly.FieldNumber(0, undefined, 10);433        assertNumberField(field, -Infinity, 10, 0, 0);434      });435      test('JSON Definition', function() {436        var field = Blockly.FieldNumber.fromJson({437          max: 10,438        });439        assertNumberField(field, -Infinity, 10, 0, 0);440      });441      test('Set Constraints', function() {442        var field = new Blockly.FieldNumber();443        field.setConstraints(undefined, 10);444        assertNumberField(field, -Infinity, 10, 0, 0);445      });446      test('Set Max', function() {447        var field = new Blockly.FieldNumber();448        field.setMax(10);449        assertNumberField(field, -Infinity, 10, 0, 0);450      });451      test('JS Configuration - Simple', function() {452        var field = new Blockly.FieldNumber(453            undefined, undefined, undefined, undefined, undefined, {454              max: 10455            });456        assertNumberField(field, -Infinity, 10, 0, 0);457      });458      test('JS Configuration - Ignore', function() {459        var field = new Blockly.FieldNumber(460            undefined, undefined, 1, undefined, undefined, {461              max: 10462            });463        assertNumberField(field, -Infinity, 10, 0, 0);464      });465    });466    suite('Precision', function() {467      test('JS Constructor', function() {468        var field = new Blockly.FieldNumber(0, undefined, undefined, 1);469        assertNumberField(field, -Infinity, Infinity, 1, 0);470      });471      test('JSON Definition', function() {472        var field = Blockly.FieldNumber.fromJson({473          precision: 1,474        });475        assertNumberField(field, -Infinity, Infinity, 1, 0);476      });477      test('Set Constraints', function() {478        var field = new Blockly.FieldNumber();479        field.setConstraints(undefined, undefined, 1);480        assertNumberField(field, -Infinity, Infinity, 1, 0);481      });482      test('Set Precision', function() {483        var field = new Blockly.FieldNumber();484        field.setPrecision(1);485        assertNumberField(field, -Infinity, Infinity, 1, 0);486      });487      test('JS Configuration - Simple', function() {488        var field = new Blockly.FieldNumber(489            undefined, undefined, undefined, undefined, undefined, {490              precision: 1491            });492        assertNumberField(field, -Infinity, Infinity, 1, 0);493      });494      test('JS Configuration - Ignore', function() {495        var field = new Blockly.FieldNumber(496            undefined, undefined, undefined, .5, undefined, {497              precision: 1498            });499        assertNumberField(field, -Infinity, Infinity, 1, 0);500      });501    });502  });...

Full Screen

Full Screen

field_angle_test.js

Source:field_angle_test.js Github

copy

Full Screen

1/**2 * @license3 * Copyright 2019 Google LLC4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 *   http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17suite('Angle Fields', function() {18  function assertValue(angleField, expectedValue, opt_expectedText) {19    var actualValue = angleField.getValue();20    var actualText = angleField.getText();21    opt_expectedText = opt_expectedText || String(expectedValue);22    assertEquals(String(actualValue), String(expectedValue));23    assertEquals(Number(actualValue), expectedValue);24    assertEquals(actualText, opt_expectedText);25  }26  function assertValueDefault(angleField) {27    assertValue(angleField, 0);28  }29  suite('Constructor', function() {30    test('Empty', function() {31      var angleField = new Blockly.FieldAngle();32      assertValueDefault(angleField);33    });34    test('Undefined', function() {35      var angleField = new Blockly.FieldAngle(undefined);36      assertValueDefault(angleField);37    });38    test('NaN', function() {39      var angleField = new Blockly.FieldAngle(NaN);40      assertValueDefault(angleField);41    });42    test('Integer', function() {43      var angleField = new Blockly.FieldAngle(1);44      assertValue(angleField, 1);45    });46    test('Float', function() {47      var angleField = new Blockly.FieldAngle(1.5);48      assertValue(angleField, 1.5);49    });50    test('Integer String', function() {51      var angleField = new Blockly.FieldAngle('1');52      assertValue(angleField, 1);53    });54    test('Float String', function() {55      var angleField = new Blockly.FieldAngle('1.5');56      assertValue(angleField, 1.5);57    });58    test('> 360°', function() {59      var angleField = new Blockly.FieldAngle(362);60      assertValue(angleField, 2);61    });62  });63  suite('fromJson', function() {64    test('Empty', function() {65      var angleField = Blockly.FieldAngle.fromJson({});66      assertValueDefault(angleField);67    });68    test('Undefined', function() {69      var angleField = Blockly.FieldAngle.fromJson({ angle:undefined });70      assertValueDefault(angleField);71    });72    test('NaN', function() {73      var angleField = Blockly.FieldAngle.fromJson({ angle:NaN });74      assertValueDefault(angleField);75    });76    test('Integer', function() {77      var angleField = Blockly.FieldAngle.fromJson({ angle:1 });78      assertValue(angleField, 1);79    });80    test('Float', function() {81      var angleField = Blockly.FieldAngle.fromJson({ angle:1.5 });82      assertValue(angleField, 1.5);83    });84    test('Integer String', function() {85      var angleField = Blockly.FieldAngle.fromJson({ angle:'1' });86      assertValue(angleField, 1);87    });88    test('Float String', function() {89      var angleField = Blockly.FieldAngle.fromJson({ angle:'1.5' });90      assertValue(angleField, 1.5);91    });92    test('> 360°', function() {93      var angleField = Blockly.FieldAngle.fromJson({ angle:362 });94      assertValue(angleField, 2);95    });96  });97  suite('setValue', function() {98    suite('Empty -> New Value', function() {99      setup(function() {100        this.angleField = new Blockly.FieldAngle();101      });102      test('Null', function() {103        this.angleField.setValue(null);104        assertValueDefault(this.angleField);105      });106      test('Undefined', function() {107        this.angleField.setValue(undefined);108        assertValueDefault(this.angleField);109      });110      test('Non-Parsable String', function() {111        this.angleField.setValue('bad');112        assertValueDefault(this.angleField);113      });114      test('NaN', function() {115        this.angleField.setValue(NaN);116        assertValueDefault(this.angleField);117      });118      test('Integer', function() {119        this.angleField.setValue(2);120        assertValue(this.angleField, 2);121      });122      test('Float', function() {123        this.angleField.setValue(2.5);124        assertValue(this.angleField, 2.5);125      });126      test('Integer String', function() {127        this.angleField.setValue('2');128        assertValue(this.angleField, 2);129      });130      test('Float', function() {131        this.angleField.setValue('2.5');132        assertValue(this.angleField, 2.5);133      });134      test('>360°', function() {135        this.angleField.setValue(362);136        assertValue(this.angleField, 2);137      });138      test('Infinity', function() {139        this.angleField.setValue(Infinity);140        assertValueDefault(this.angleField);141      });142      test('Negative Infinity String', function() {143        this.angleField.setValue('-Infinity');144        assertValueDefault(this.angleField);145      });146    });147    suite('Value -> New Value', function() {148      setup(function() {149        this.angleField = new Blockly.FieldAngle(1);150      });151      test('Null', function() {152        this.angleField.setValue(null);153        assertValue(this.angleField, 1);154      });155      test('Undefined', function() {156        this.angleField.setValue(undefined);157        assertValue(this.angleField, 1);158      });159      test('Non-Parsable String', function() {160        this.angleField.setValue('bad');161        assertValue(this.angleField, 1);162      });163      test('NaN', function() {164        this.angleField.setValue(NaN);165        assertValue(this.angleField, 1);166      });167      test('Integer', function() {168        this.angleField.setValue(2);169        assertValue(this.angleField, 2);170      });171      test('Float', function() {172        this.angleField.setValue(2.5);173        assertValue(this.angleField, 2.5);174      });175      test('Integer String', function() {176        this.angleField.setValue('2');177        assertValue(this.angleField, 2);178      });179      test('Float', function() {180        this.angleField.setValue('2.5');181        assertValue(this.angleField, 2.5);182      });183      test('>360°', function() {184        this.angleField.setValue(362);185        assertValue(this.angleField, 2);186      });187      test('Infinity', function() {188        this.angleField.setValue(Infinity);189        assertValue(this.angleField, 1);190      });191      test('Negative Infinity String', function() {192        this.angleField.setValue('-Infinity');193        assertValue(this.angleField, 1);194      });195    });196  });197  suite('Validators', function() {198    setup(function() {199      this.angleField = new Blockly.FieldAngle(1);200      this.angleField.htmlInput_ = Object.create(null);201      this.angleField.htmlInput_.oldValue_ = '1';202      this.angleField.htmlInput_.untypedDefaultValue_ = 1;203      this.stub = sinon.stub(this.angleField, 'resizeEditor_');204    });205    teardown(function() {206      this.angleField.setValidator(null);207      this.angleField.htmlInput_ = null;208      if (this.stub) {209        this.stub.restore();210      }211    });212    suite('Null Validator', function() {213      setup(function() {214        this.angleField.setValidator(function() {215          return null;216        });217      });218      test('When Editing', function() {219        this.angleField.isBeingEdited_ = true;220        this.angleField.htmlInput_.value = '2';221        this.angleField.onHtmlInputChange_(null);222        assertValue(this.angleField, 1, '2');223        this.angleField.isBeingEdited_ = false;224      });225      test('When Not Editing', function() {226        this.angleField.setValue(2);227        assertValue(this.angleField, 1);228      });229    });230    suite('Force Mult of 30 Validator', function() {231      setup(function() {232        this.angleField.setValidator(function(newValue) {233          return Math.round(newValue / 30) * 30;234        });235      });236      test('When Editing', function() {237        this.angleField.isBeingEdited_ = true;238        this.angleField.htmlInput_.value = '25';239        this.angleField.onHtmlInputChange_(null);240        assertValue(this.angleField, 30, '25');241        this.angleField.isBeingEdited_ = false;242      });243      test('When Not Editing', function() {244        this.angleField.setValue(25);245        assertValue(this.angleField, 30);246      });247    });248    suite('Returns Undefined Validator', function() {249      setup(function() {250        this.angleField.setValidator(function() {});251      });252      test('When Editing', function() {253        this.angleField.isBeingEdited_ = true;254        this.angleField.htmlInput_.value = '2';255        this.angleField.onHtmlInputChange_(null);256        assertValue(this.angleField, 2);257        this.angleField.isBeingEdited_ = false;258      });259      test('When Not Editing', function() {260        this.angleField.setValue(2);261        assertValue(this.angleField, 2);262      });263    });264  });265  suite('Customizations', function() {266    suite('Clockwise', function() {267      test('JS Configuration', function() {268        var field = new Blockly.FieldAngle(0, null, {269          clockwise: true270        });271        chai.assert.isTrue(field.clockwise_);272      });273      test('JSON Definition', function() {274        var field = Blockly.FieldAngle.fromJson({275          value: 0,276          clockwise: true277        });278        chai.assert.isTrue(field.clockwise_);279      });280      test('Constant', function() {281        // Note: Generally constants should be set at compile time, not282        // runtime (since they are constants) but for testing purposes we283        // can do this.284        Blockly.FieldAngle.CLOCKWISE = true;285        var field = new Blockly.FieldAngle();286        chai.assert.isTrue(field.clockwise_);287      });288    });289    suite('Offset', function() {290      test('JS Configuration', function() {291        var field = new Blockly.FieldAngle(0, null, {292          offset: 90293        });294        chai.assert.equal(field.offset_, 90);295      });296      test('JSON Definition', function() {297        var field = Blockly.FieldAngle.fromJson({298          value: 0,299          offset: 90300        });301        chai.assert.equal(field.offset_, 90);302      });303      test('Constant', function() {304        // Note: Generally constants should be set at compile time, not305        // runtime (since they are constants) but for testing purposes we306        // can do this.307        Blockly.FieldAngle.OFFSET = 90;308        var field = new Blockly.FieldAngle();309        chai.assert.equal(field.offset_, 90);310      });311      test('Null', function() {312        // Note: Generally constants should be set at compile time, not313        // runtime (since they are constants) but for testing purposes we314        // can do this.315        Blockly.FieldAngle.OFFSET = 90;316        var field = Blockly.FieldAngle.fromJson({317          value: 0,318          offset: null319        });320        chai.assert.equal(field.offset_, 90);321      });322    });323    suite('Wrap', function() {324      test('JS Configuration', function() {325        var field = new Blockly.FieldAngle(0, null, {326          wrap: 180327        });328        chai.assert.equal(field.wrap_, 180);329      });330      test('JSON Definition', function() {331        var field = Blockly.FieldAngle.fromJson({332          value: 0,333          wrap: 180334        });335        chai.assert.equal(field.wrap_, 180);336      });337      test('Constant', function() {338        // Note: Generally constants should be set at compile time, not339        // runtime (since they are constants) but for testing purposes we340        // can do this.341        Blockly.FieldAngle.WRAP = 180;342        var field = new Blockly.FieldAngle();343        chai.assert.equal(field.wrap_, 180);344      });345      test('Null', function() {346        // Note: Generally constants should be set at compile time, not347        // runtime (since they are constants) but for testing purposes we348        // can do this.349        Blockly.FieldAngle.WRAP = 180;350        var field = Blockly.FieldAngle.fromJson({351          value: 0,352          wrap: null353        });354        chai.assert.equal(field.wrap_, 180);355      });356    });357    suite('Round', function() {358      test('JS Configuration', function() {359        var field = new Blockly.FieldAngle(0, null, {360          round: 30361        });362        chai.assert.equal(field.round_, 30);363      });364      test('JSON Definition', function() {365        var field = Blockly.FieldAngle.fromJson({366          value: 0,367          round: 30368        });369        chai.assert.equal(field.round_, 30);370      });371      test('Constant', function() {372        // Note: Generally constants should be set at compile time, not373        // runtime (since they are constants) but for testing purposes we374        // can do this.375        Blockly.FieldAngle.ROUND = 30;376        var field = new Blockly.FieldAngle();377        chai.assert.equal(field.round_, 30);378      });379      test('Null', function() {380        // Note: Generally constants should be set at compile time, not381        // runtime (since they are constants) but for testing purposes we382        // can do this.383        Blockly.FieldAngle.ROUND = 30;384        var field = Blockly.FieldAngle.fromJson({385          value: 0,386          round: null387        });388        chai.assert.equal(field.round_, 30);389      });390    });391    suite('Mode', function() {392      suite('Compass', function() {393        test('JS Configuration', function() {394          var field = new Blockly.FieldAngle(0, null, {395            mode: 'compass'396          });397          chai.assert.equal(field.offset_, 90);398          chai.assert.isTrue(field.clockwise_);399        });400        test('JS Configuration', function() {401          var field = Blockly.FieldAngle.fromJson({402            value: 0,403            mode: 'compass'404          });405          chai.assert.equal(field.offset_, 90);406          chai.assert.isTrue(field.clockwise_);407        });408      });409      suite('Protractor', function() {410        test('JS Configuration', function() {411          var field = new Blockly.FieldAngle(0, null, {412            mode: 'protractor'413          });414          chai.assert.equal(field.offset_, 0);415          chai.assert.isFalse(field.clockwise_);416        });417        test('JS Configuration', function() {418          var field = Blockly.FieldAngle.fromJson({419            value: 0,420            mode: 'protractor'421          });422          chai.assert.equal(field.offset_, 0);423          chai.assert.isFalse(field.clockwise_);424        });425      });426    });427  });...

Full Screen

Full Screen

Date.js

Source:Date.js Github

copy

Full Screen

...18    });19    describe("setValue", function() {20        it("should take accept a date object", function() {21            makeField();22            field.setValue(new Date(2010, 0, 1));23            expect(field.getValue()).toEqual(new Date(2010, 0, 1));24        });25        it("should accept a string that matches the dateFormat", function() {26            makeField({27                dateFormat: 'Y-m-d'28            });29            field.setValue('2010-01-01');30            expect(field.getValue()).toEqual(new Date(2010, 0, 1));31        });32        it("should return null for a string that cannot be parsed", function() {33            makeField({34                dateFormat: 'Y-m-d'35            });36            field.setValue('01/50/2010');37            expect(field.getValue()).toBe(null);38        });39        it("should update the text field with the formatted value when specifying a date", function() {40            makeField({41                dateFormat: 'Y-m-d'42            });43            field.setValue(new Date(2010, 0, 1));44            expect(field.inputElement.dom.value).toBe('2010-01-01');45        });46        it("should clear the text field when specifying null", function() {47            makeField({48                dateFormat: 'Y-m-d'49            });50            field.setValue(new Date(2010, 0, 1));51            field.setValue(null);52            expect(field.inputElement.dom.value).toBe('');53        });54        describe("events", function() {55            var spy;56            beforeEach(function() {57                spy = jasmine.createSpy();58                makeField();59                field.on('change', spy);60            });61            afterEach(function() {62                spy = null;63            });64            it("should fire the change event when setting a value", function() {65                field.setValue(new Date(2010, 0, 1));66                expect(spy.callCount).toBe(1);67                expect(spy.mostRecentCall.args[0]).toBe(field);68                expect(spy.mostRecentCall.args[1]).toEqual(new Date(2010, 0, 1));69                expect(spy.mostRecentCall.args[2]).toBeNull(field);70            });71            it("should fire the change event when changing a value", function() {72                field.setValue(new Date(2010, 0, 1));73                spy.reset();74                field.setValue(new Date(2010, 11, 31));75                expect(spy.callCount).toBe(1);76                expect(spy.mostRecentCall.args[0]).toBe(field);77                expect(spy.mostRecentCall.args[1]).toEqual(new Date(2010, 11, 31));78                expect(spy.mostRecentCall.args[2]).toEqual(new Date(2010, 0, 1));79            });80            it("should fire the change event when clearing a value", function() {81                field.setValue(new Date(2010, 0, 1));82                spy.reset();83                field.setValue(null);84                expect(spy.callCount).toBe(1);85                expect(spy.mostRecentCall.args[0]).toBe(field);86                expect(spy.mostRecentCall.args[1]).toBeNull();87                expect(spy.mostRecentCall.args[2]).toEqual(new Date(2010, 0, 1));88            });89            it("should not fire the change event when setting the same date", function() {90                field.setValue(new Date(2010, 0, 1));91                spy.reset();92                field.setValue(new Date(2010, 0, 1));93                expect(spy).not.toHaveBeenCalled();94            });95        });96    });97    describe("getValue", function() {98        it("should return a date object when configured with a value", function() {99            makeField({100                value: new Date(2010, 0, 1)101            });102            expect(field.getValue()).toEqual(new Date(2010, 0, 1));103        });104        it("should return a date object after having a value set", function() {105            makeField();106            field.setValue(new Date(2010, 0, 1));107            expect(field.getValue()).toEqual(new Date(2010, 0, 1));108        });109        it("should return null when not configured with a value", function() {110            makeField();111            expect(field.getValue()).toBeNull();112        });113        it("should return null after clearing a value", function() {114            makeField({115                value: new Date(2010, 0, 1)116            });117            field.setValue(null);118            expect(field.getValue()).toBeNull();119        });120    });121    describe("getFormattedValue", function() {122        it("should return the formatted value when configured with a value", function() {123            makeField({124                dateFormat: 'Y-m-d',125                value: new Date(2010, 0, 1)126            });127            expect(field.getFormattedValue()).toBe('2010-01-01');128        });129        it("should return the formatted value after having a value set", function() {130            makeField({131                dateFormat: 'Y-m-d'132            });133            field.setValue(new Date(2010, 0, 1));134            expect(field.getFormattedValue()).toBe('2010-01-01');135        });136        it("should favour a passed format over the class format", function() {137            makeField({138                dateFormat: 'd/m/Y'139            });140            field.setValue(new Date(2010, 0, 1));141            expect(field.getFormattedValue('Y-m-d')).toBe('2010-01-01');142        });143        it("should return '' when not configured with a value", function() {144            makeField();145            expect(field.getFormattedValue()).toBe('');146        });147        it("should return '' after clearing a value", function() {148            makeField({149                value: new Date(2010, 0, 1)150            });151            field.setValue(null);152            expect(field.getFormattedValue()).toBe('');153        });154    });155    describe("minDate", function() {156        it("should accept Date object", function() {157            makeField({158                minDate: new Date()159            });160            expect(field.getMinDate()).toEqual(today);161        });162        it("should accept string in dateFormat", function() {163            makeField({164                minDate: Ext.Date.format(today, Ext.util.Format.defaultDateFormat)165            });166            expect(field.getMinDate()).toEqual(today);167        });168    });169    describe("maxDate", function() {170        it("should accept Date object", function() {171            makeField({172                maxDate: new Date()173            });174            expect(field.getMaxDate()).toEqual(today);175        });176        it("should accept string in dateFormat", function() {177            makeField({178                maxDate: Ext.Date.format(today, Ext.util.Format.defaultDateFormat)179            });180            expect(field.getMaxDate()).toEqual(today);181        });182    });183    describe("picker", function() {184        var oldPlatformTags;185        beforeEach(function() {186            oldPlatformTags = Ext.merge({}, Ext.platformTags);187        });188        afterEach(function() {189            Ext.platformTags = oldPlatformTags;190        });191        it("should create only one date trigger", function() {192            makeField();193            expect(field.afterInputElement.dom.children.length).toBe(1);194        });195        it("should choose edge picker on a phone", function() {196            Ext.platformTags.phone = true;197            makeField();198            var picker = field.getPicker();199            expect(picker.xtype).toBe('datepicker');200        });201        it("should choose floated picker when not on a phone", function() {202            Ext.platformTags.phone = false;203            makeField();204            var picker = field.getPicker();205            expect(picker.xtype).toBe('datepanel');206        });207        it('should set value onto edge picker', function () {208            makeField();209            var date = new Date();210            date.setHours(0);211            date.setMinutes(0);212            date.setSeconds(0);213            date.setMilliseconds(0);214            Ext.platformTags.phone = true;215            field.setValue(date);216            field.expand();217            expect(field.getPicker().getValue()).toEqual(new Date(date));218        });219        it('should set value onto floated picker', function () {220            makeField();221            var date = new Date();222            date.setHours(0);223            date.setMinutes(0);224            date.setSeconds(0);225            date.setMilliseconds(0);226            field.setValue(date);227            field.expand();228            expect(field.getPicker().getValue()).toEqual(new Date(date));229        });230        describe("picker with invalid value", function() {231            function runIt(type) {232                var D = Ext.Date,233                    now = D.clearTime(new Date(), true);234                makeField({235                    picker: type236                });237                field.inputElement.dom.value = 'asdf';238                field.showPicker();239                expect(D.clearTime(field.getPicker().getValue(), true)).toEqual(now);240            }241            it("should set the current date with picker: edge", function() {242                runIt('edge');243            });244            it("should set the current date with picker: floated", function() {245                runIt('floated');246            });247        });248    });249    describe('validate', function () {250        it('should validate date object', function () {251            makeField({252                validators: 'date'253            });254            field.setValue(new Date());255            expect(field.validate()).toBe(true);256        });257        it('should validate date string', function () {258            makeField({259                validators: 'date'260            });261            field.setValue('01/01/2017');262            expect(field.validate()).toBe(true);263        });264    });265    describe("empty value", function() {266        it("should be able to clear the value", function() {267            makeField({268                value: new Date()269            });270            // Simulate selecting the text and backspacing it out271            // Firing key events for backspace don't end up triggering272            // onInput273            field.inputElement.dom.value = '';274            field.onInput({});275            expect(field.getValue()).toBeNull();...

Full Screen

Full Screen

field_date_test.js

Source:field_date_test.js Github

copy

Full Screen

1/**2 * @license3 * Copyright 2019 Google LLC4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 *   http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17/* If you want to run date tests add the date picker here:18 * https://github.com/google/blockly/blob/master/core/blockly.js#L4119 * before unskipping.20 */21suite.skip('Date Fields', function() {22  function assertValue(dateField, expectedValue) {23    var actualValue = dateField.getValue();24    var actualText = dateField.getText();25    assertEquals(actualValue, expectedValue);26    assertEquals(actualText, expectedValue);27  }28  function assertValueDefault(dateField) {29    var today = new goog.date.Date().toIsoString(true);30    assertValue(dateField, today);31  }32  suite('Constructor', function() {33    test('Empty', function() {34      var dateField = new Blockly.FieldDate();35      assertValueDefault(dateField);36    });37    test('Undefined', function() {38      var dateField = new Blockly.FieldDate(undefined);39      assertValueDefault(dateField);40    });41    test('Non-Parsable String', function() {42      var dateField = new Blockly.FieldDate('bad');43      assertValueDefault(dateField);44    });45    test('2020-02-20', function() {46      var dateField = new Blockly.FieldDate('2020-02-20');47      assertValue(dateField, '2020-02-20');48    });49    test('Invalid Date - Month(2020-13-20)', function() {50      var dateField = new Blockly.FieldDate('2020-13-20');51      assertValueDefault(dateField);52    });53    test('Invalid Date - Day(2020-02-32)', function() {54      var dateField = new Blockly.FieldDate('2020-02-32');55      assertValueDefault(dateField);56    });57  });58  suite('fromJson', function() {59    test('Empty', function() {60      var dateField = Blockly.FieldDate.fromJson({});61      assertValueDefault(dateField);62    });63    test('Undefined', function() {64      var dateField = Blockly.FieldDate.fromJson({ date: undefined });65      assertValueDefault(dateField);66    });67    test('Non-Parsable String', function() {68      var dateField = Blockly.FieldDate.fromJson({ date: 'bad' });69      assertValueDefault(dateField);70    });71    test('2020-02-20', function() {72      var dateField = Blockly.FieldDate.fromJson({ date: '2020-02-20' });73      assertValue(dateField, '2020-02-20');74    });75    test('Invalid Date - Month(2020-13-20)', function() {76      var dateField = Blockly.FieldDate.fromJson({ date: '2020-13-20' });77      assertValueDefault(dateField);78    });79    test('Invalid Date - Day(2020-02-32)', function() {80      var dateField = Blockly.FieldDate.fromJson({ date: '2020-02-32' });81      assertValueDefault(dateField);82    });83  });84  suite('setValue', function() {85    suite('Empty -> New Value', function() {86      setup(function() {87        this.dateField = new Blockly.FieldDate();88      });89      test('Null', function() {90        this.dateField.setValue(null);91        assertValueDefault(this.dateField);92      });93      test('Undefined', function() {94        this.dateField.setValue(undefined);95        assertValueDefault(this.dateField);96      });97      test('Non-Parsable String', function() {98        this.dateField.setValue('bad');99        assertValueDefault(this.dateField);100      });101      test('Invalid Date - Month(2020-13-20)', function() {102        this.dateField.setValue('2020-13-20');103        assertValueDefault(this.dateField);104      });105      test('Invalid Date - Day(2020-02-32)', function() {106        this.dateField.setValue('2020-02-32');107        assertValueDefault(this.dateField);108      });109      test('3030-03-30', function() {110        this.dateField.setValue('3030-03-30');111        assertValue(this.dateField, '3030-03-30');112      });113    });114    suite('Value -> New Value', function() {115      setup(function() {116        this.dateField = new Blockly.FieldDate('2020-02-20');117      });118      test('Null', function() {119        this.dateField.setValue(null);120        assertValue(this.dateField, '2020-02-20');121      });122      test('Undefined', function() {123        this.dateField.setValue(undefined);124        assertValue(this.dateField, '2020-02-20');125      });126      test('Non-Parsable String', function() {127        this.dateField.setValue('bad');128        assertValue(this.dateField, '2020-02-20');129      });130      test('Invalid Date - Month(2020-13-20)', function() {131        this.dateField.setValue('2020-13-20');132        assertValue(this.dateField, '2020-02-20');133      });134      test('Invalid Date - Day(2020-02-32)', function() {135        this.dateField.setValue('2020-02-32');136        assertValue(this.dateField, '2020-02-20');137      });138      test('3030-03-30', function() {139        this.dateField.setValue('3030-03-30');140        assertValue(this.dateField, '3030-03-30');141      });142    });143  });144  suite('Validators', function() {145    setup(function() {146      this.dateField = new Blockly.FieldDate('2020-02-20');147    });148    teardown(function() {149      this.dateField.setValidator(null);150    });151    suite('Null Validator', function() {152      setup(function() {153        this.dateField.setValidator(function() {154          return null;155        });156      });157      test('New Value', function() {158        this.dateField.setValue('3030-03-30');159        assertValue(this.dateField, '2020-02-20');160      });161    });162    suite('Force Day 20s Validator', function() {163      setup(function() {164        this.dateField.setValidator(function(newValue) {165          return newValue.substr(0, 8) + '2' + newValue.substr(9, 1);166        });167      });168      test('New Value', function() {169        this.dateField.setValue('3030-03-30');170        assertValue(this.dateField, '3030-03-20');171      });172    });173    suite('Returns Undefined Validator', function() {174      setup(function() {175        this.dateField.setValidator(function() {});176      });177      test('New Value', function() {178        this.dateField.setValue('3030-03-30');179        assertValue(this.dateField, '3030-03-30');180      });181    });182  });...

Full Screen

Full Screen

DatePicker.js

Source:DatePicker.js Github

copy

Full Screen

...1314    describe("setValue", function() {15        it("should take accept a date object", function() {16            makeField();17            field.setValue(new Date(2010, 0, 1));18            expect(field.getValue()).toEqual(new Date(2010, 0, 1));19        });2021        it("should accept a string that matches the dateFormat", function() {22            makeField({23                dateFormat: 'Y-m-d'24            });25            field.setValue('2010-01-01');26            expect(field.getValue()).toEqual(new Date(2010, 0, 1));27        });2829        it("should return null for a string that does not match the format", function() {30            makeField({31                dateFormat: 'Y-m-d'32            });33            field.setValue('01/01/2010');34            expect(field.getValue()).toBeNull();35        });3637        it("should update the text field with the formatted value when specifying a date", function() {38            makeField({39                dateFormat: 'Y-m-d'40            });41            field.setValue(new Date(2010, 0, 1));42            expect(field.getComponent().input.dom.value).toBe('2010-01-01');43        });4445        it("should clear the text field when specifying null", function() {46            makeField({47                dateFormat: 'Y-m-d'48            });49            field.setValue(new Date(2010, 0, 1));50            field.setValue(null);51            expect(field.getComponent().input.dom.value).toBe('');52        });5354        describe("events", function() {55            var spy;56            beforeEach(function() {57                spy = jasmine.createSpy();58                makeField();59                field.on('change', spy);60            });6162            afterEach(function() {63                spy = null;64            });6566            it("should fire the change event when setting a value", function() {67                field.setValue(new Date(2010, 0, 1));68                expect(spy.callCount).toBe(1);69                expect(spy.mostRecentCall.args[0]).toBe(field);70                expect(spy.mostRecentCall.args[1]).toEqual(new Date(2010, 0, 1));71                expect(spy.mostRecentCall.args[2]).toBeNull(field);72            });7374            it("should fire the change event when changing a value", function() {75                field.setValue(new Date(2010, 0, 1));76                spy.reset();77                field.setValue(new Date(2010, 11, 31));78                expect(spy.callCount).toBe(1);79                expect(spy.mostRecentCall.args[0]).toBe(field);80                expect(spy.mostRecentCall.args[1]).toEqual(new Date(2010, 11, 31));81                expect(spy.mostRecentCall.args[2]).toEqual(new Date(2010, 0, 1));82            });8384            it("should fire the change event when clearing a value", function() {85                field.setValue(new Date(2010, 0, 1));86                spy.reset();87                field.setValue(null);88                expect(spy.callCount).toBe(1);89                expect(spy.mostRecentCall.args[0]).toBe(field);90                expect(spy.mostRecentCall.args[1]).toBeNull();91                expect(spy.mostRecentCall.args[2]).toEqual(new Date(2010, 0, 1));92            });9394            it("should not fire the change event when setting the same date", function() {95                field.setValue(new Date(2010, 0, 1));96                spy.reset();97                field.setValue(new Date(2010, 0, 1));98                expect(spy).not.toHaveBeenCalled();99            });100        });101    });102103    describe("getValue", function() {104        it("should return a date object when configured with a value", function() {105            makeField({106                value: new Date(2010, 0, 1)107            });108            expect(field.getValue()).toEqual(new Date(2010, 0, 1));109        });110111        it("should return a date object after having a value set", function() {112            makeField();113            field.setValue(new Date(2010, 0, 1));114            expect(field.getValue()).toEqual(new Date(2010, 0, 1));115        });116117        it("should return null when not configured with a value", function() {118            makeField();119            expect(field.getValue()).toBeNull();120        });121122        it("should return null after clearing a value", function() {123            makeField({124                value: new Date(2010, 0, 1)125            });126            field.setValue(null);127            expect(field.getValue()).toBeNull();128        });129    });130131    describe("getFormattedValue", function() {132        it("should return the formatted value when configured with a value", function() {133            makeField({134                dateFormat: 'Y-m-d',135                value: new Date(2010, 0, 1)136            });137            expect(field.getFormattedValue()).toBe('2010-01-01');138        });139140        it("should return the formatted value after having a value set", function() {141            makeField({142                dateFormat: 'Y-m-d'143            });144            field.setValue(new Date(2010, 0, 1));145            expect(field.getFormattedValue()).toBe('2010-01-01');146        });147148        it("should favour a passed format over the class format", function() {149            makeField({150                dateFormat: 'd/m/Y'151            });152            field.setValue(new Date(2010, 0, 1));153            expect(field.getFormattedValue('Y-m-d')).toBe('2010-01-01');154        });155156        it("should return '' when not configured with a value", function() {157            makeField();158            expect(field.getFormattedValue()).toBe('');159        });160161        it("should return '' after clearing a value", function() {162            makeField({163                value: new Date(2010, 0, 1)164            });165            field.setValue(null);166            expect(field.getFormattedValue()).toBe('');167        });168    });169170
...

Full Screen

Full Screen

login.page.js

Source:login.page.js Github

copy

Full Screen

1import Page from './Page';2class LoginPage extends Page {3	get registerButton() { return browser.element('button.register'); }4	get forgotPasswordButton() { return browser.element('button.forgot-password'); }5	get backToLoginButton() { return browser.element('button.back-to-login'); }6	get submitButton() { return browser.element('.submit > button'); }7	get emailOrUsernameField() { return browser.element('[name=emailOrUsername]'); }8	get nameField() { return browser.element('[name=name]'); }9	get emailField() { return browser.element('[name=email]'); }10	get passwordField() { return browser.element('[name=pass]'); }11	get confirmPasswordField() { return browser.element('[name=confirm-pass]'); }12	get inputUsername() { return browser.element('form#login-card input#username'); }13	get emailOrUsernameInvalidText() { return browser.element('[name=emailOrUsername]~.input-error'); }14	get nameInvalidText() { return browser.element('[name=name]~.input-error'); }15	get emailInvalidText() { return browser.element('[name=email]~.input-error'); }16	get passwordInvalidText() { return browser.element('[name=pass]~.input-error'); }17	get confirmPasswordInvalidText() { return browser.element('[name=confirm-pass]~.input-error'); }18	open() {19		super.open('');20	}21	gotToRegister() {22		this.registerButton.waitForVisible(5000);23		this.registerButton.click();24	}25	gotToForgotPassword() {26		this.forgotPasswordButton.waitForVisible(5000);27		this.forgotPasswordButton.click();28	}29	registerNewUser({username, email, password}) {30		this.nameField.waitForVisible(5000);31		this.nameField.setValue(username);32		this.emailField.setValue(email);33		this.passwordField.setValue(password);34		this.confirmPasswordField.setValue(password);35		this.submit();36	}37	registerNewAdmin({adminUsername, adminEmail, adminPassword}) {38		this.nameField.waitForVisible(5000);39		this.nameField.setValue(adminUsername);40		this.emailField.setValue(adminEmail);41		this.passwordField.setValue(adminPassword);42		this.confirmPasswordField.setValue(adminPassword);43		this.submit();44	}45	login({email, password}) {46		this.emailOrUsernameField.waitForVisible(5000);47		this.emailOrUsernameField.setValue(email);48		this.passwordField.setValue(password);49		this.submit();50	}51	submit() {52		this.submitButton.waitForVisible(5000);53		this.submitButton.click();54	}55}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1field.setValue("My value");2field.click();3field.submit();4field.clear();5field.getAttribute("attributeName");6field.getCssValue("cssProperty");7field.getTagName();8field.getText();9field.getSize();10field.getLocation();11field.getLocationInView();12field.isDisplayed();13field.isEnabled();14field.isSelected();15field.isDisplayed();16field.getLocationInView();17field.isDisplayed();18field.getLocationInView();19field.isDisplayed();20field.getLocationInView();21field.isDisplayed();22field.getLocationInView();23field.isDisplayed();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var browser = wd.remote();4browser.init({5}, function() {6    browser.elementById('lst-ib', function(err, element) {7      element.setValue("hello world", function() {8        browser.elementById('lst-ib', function(err, element) {9          element.getAttribute('value', function(err, value) {10            assert.equal(value, "hello world");11            browser.quit();12          });13        });14      });15    });16  });17});

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.executeScript("mobile:setValue", {element: field, value: value});2driver.executeScript("mobile:setValue", {element: field, value: value});3driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "next", offset: 0.15});4driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "previous", offset: 0.15});5driver.executeScript("mobile:setValue", {element: field, value: value});6driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "next", offset: 0.15});7driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "previous", offset: 0.15});8driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "next", offset: 0.15});9driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "previous", offset: 0.15});10driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "next", offset: 0.15});11driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "previous", offset: 0.15});12driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "next", offset: 0.15});13driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "previous", offset: 0.15});14driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "next", offset: 0.15});15driver.executeScript("mobile:selectPickerWheelValue", {element: field, order: "previous", offset: 0.15});16driver.executeScript("mobile:selectPickerWheelValue", {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var fs = require('fs');3var assert = require('assert');4var desired = {5};6fs.readFile('value.txt', 'utf8', function (err,data) {7  if (err) {8    return console.log(err);9  }10  console.log(data);11  var value = data;12  console.log(value);13  wd.remote('localhost', 4723).init(desired, function(err, browser) {14      browser.elementById('lst-ib', function(err, el) {15        el.clear(function() {16          el.sendKeys(value, function() {17            browser.elementById('lst-ib', function(err, el) {18              el.getValue(function(err, value) {19                assert.equal(value, 'hello world');20                browser.quit();21              });22            });23          });24        });25      });26    });27  });28});

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