Best JavaScript code snippet using testcafe
ball.js
Source:ball.js  
1import vector from "./vector";2import * as THREE from "three";3import { Vector3 } from "three";4class Ball {5  constructor(6    position,7    speed,8    angleXY,9    angleXZ,10    raduis,11    type,12    mass,13    drag_coeff,14    angular_velocity,15    resistanse_coeff,16    friction_coeff17  ) {18    this.position = position;19    this.velocity = vector.create(0, 0, 0);20    this.velocity.inits(speed, angleXY, angleXZ);21    this.type = type;22    this.drag_coeff = drag_coeff;23    this.rolling = false;24    this.resistanse_coeff = resistanse_coeff;25    this.friction_coeff = friction_coeff;26    this.raduis = raduis; //m27    this.rho = 0;28    if (this.type == 1) {29      this.rho = 500; // kg/m^3  wood30      this.resistanse_coeff = 0.4603;31      this.friction_coeff = 0.4;32    } else if (this.type == 2) {33      this.rho = 7860; // steel34      this.resistanse_coeff = 0.597;35      this.friction_coeff = 0.7;36    } else if (this.type == 3) {37      this.rho = 1100; // rubber38      this.resistanse_coeff = 0.828;39      this.friction_coeff = 0.7;40    }41    if (this.type == 0) {42      // user value43      this.mass = mass;44    } else {45      this.mass = this.rho * (4 / 3) * Math.PI * Math.pow(this.raduis, 3); //kg46    }47    this.area = Math.PI * Math.pow(this.raduis, 2);48    this.rotateAngle = 0;49    this.rotateAxes = vector.create(50      angular_velocity.getX() > 0 ? 1 : 0,51      angular_velocity.getY(),52      angular_velocity.getZ()53    );54    this.angular_velocity = angular_velocity;55    this.angular_acc = new THREE.Vector3();56    const I = (2 / 5) * this.mass * Math.pow(this.raduis, 2);57    this.IBody = new THREE.Matrix3().set(I, 0, 0, 0, I, 0, 0, 0, I).invert();58    this.quaternion = new THREE.Quaternion();59    this.rotationMatrix = new THREE.Matrix3();60    this.intersectsObjects = [];61  }62  update(time, gravity, air_rho, wind_velo) {63    //Forces64    let gravityForce = this.gravity_force(gravity);65    let dragForce = this.drag_force(air_rho);66    let windForce = this.wind_force(air_rho, wind_velo);67    let liftForce = this.lift_force(air_rho);68    let buoynancyForce = this.buoyancy_force(air_rho, gravity);69    let totalForce = vector.create(70      dragForce.getX() + windForce.getX() + liftForce.getX(),71      gravityForce.getY() +72        dragForce.getY() +73        liftForce.getY() +74        buoynancyForce,75      dragForce.getZ() + windForce.getZ() + liftForce.getZ()76    );77    //Linear Movement78    if (this.rolling) gravityForce.setY(0);79    let acc = vector.create(80      totalForce.getX() / this.mass,81      totalForce.getY() / this.mass,82      totalForce.getZ() / this.mass83    );84    this.velocity.addTo(acc, time);85    if (!this.rolling) {86      this.position.x += this.velocity.getX() * time * 10;87      this.position.y += this.velocity.getY() * time * 10;88      this.position.z -= this.velocity.getZ() * time * 10;89    } else {90      this.position.x -=91        Number(this.angular_velocity._z.toFixed(2)) * this.raduis * time * 10;92      this.position.z +=93        Number(this.angular_velocity._x.toFixed(2)) * this.raduis * time * 10;94    }95    let interiaTensor = this.rotationMatrix96      .clone()97      .multiply(this.IBody)98      .multiply(this.rotationMatrix.clone().transpose());99    let viscousTorque = this.viscousTorque();100    //Total Torques101    let rollingTrouqe = vector.create(0, 0, 0);102    let torque = new Vector3();103    if (this.rolling) {104      rollingTrouqe = this.getTotalRollingTrouqe(105        gravity,106        this.wind_force(air_rho, wind_velo),107        time108      );109      torque = new Vector3(rollingTrouqe._x, 0, rollingTrouqe._z);110    } else {111      torque = new Vector3(112        viscousTorque.getX(),113        viscousTorque.getY(),114        viscousTorque.getZ()115      );116    }117    //Angular Movement118    this.angular_acc = torque.applyMatrix3(interiaTensor);119    if (!this.rolling) {120      this.angular_velocity._x += this.angular_acc.x * time;121      this.angular_velocity._y += this.angular_acc.y * time;122      this.angular_velocity._z += this.angular_acc.z * time;123    } else {124      this.angular_velocity._x += this.angular_acc.x * time;125      this.angular_velocity._z += this.angular_acc.z * time;126    }127    //Update angular velocity, quaternion128    this.updateQuaternion(this.angular_velocity, time);129    this.updateRotationMatrix(this.quaternion.normalize());130    //bouncing131    this.bouncing();132  }133  gravity_force(gravity) {134    return vector.create(0, -gravity * this.mass, 0);135  }136  drag_force(rho) {137    let velocitySquere = this.velocity.squere();138    let normalize = this.velocity.normalize();139    let drag = vector.create(140      ((velocitySquere * -1) / 2) *141        this.drag_coeff *142        rho *143        this.area *144        normalize.getX(),145      ((velocitySquere * -1) / 2) *146        this.drag_coeff *147        rho *148        this.area *149        normalize.getY(),150      ((velocitySquere * -1) / 2) *151        this.drag_coeff *152        rho *153        this.area *154        normalize.getZ()155    );156    return drag;157  }158  wind_force(rho, wind_velo) {159    let velocitySquere = wind_velo.squere();160    let normalize = wind_velo.normalize();161    let wind = vector.create(162      ((velocitySquere * 1) / 2) * rho * this.area * normalize.getX(),163      0,164      ((velocitySquere * 1) / 2) * rho * this.area * normalize.getZ()165    );166    return wind;167  }168  lift_force(rho) {169    let lift_coeff =170      -0.05 +171      Math.sqrt(172        0.0025 +173          (0.36 * this.raduis * this.angular_velocity.getLength()) /174            this.velocity.getLength()175      ); // cl=r*Ï/v176    let velocitySquere = this.velocity.squere();177    let cross = this.rotateAxes.cross(this.velocity);178    let lift = vector.create(179      ((velocitySquere * 1) / 2) * lift_coeff * rho * this.area * cross.getX(),180      ((-velocitySquere * 1) / 2) * lift_coeff * rho * this.area * cross.getY(),181      ((velocitySquere * 1) / 2) * lift_coeff * rho * this.area * cross.getZ()182    );183    return lift;184  }185  buoyancy_force(air_density, gravity) {186    let v = (4 / 3) * Math.PI * Math.pow(this.raduis, 3);187    let f = v * air_density * gravity;188    return f;189  }190  viscousTorque() {191    let v = vector.create(192      -this.angular_velocity.getX(),193      -this.angular_velocity.getY(),194      -this.angular_velocity.getZ()195    );196    let len =197      this.angular_velocity.getLength() *198      -8 *199      this.raduis *200      this.raduis *201      this.raduis *202      Math.PI *203      0.0000185;204    v.setLength(len);205    return v;206  }207  frictionTorque(gravity) {208    return this.mass * gravity * this.friction_coeff * this.raduis;209  }210  getTotalRollingTrouqe(gravity, windForce, time) {211    let friction = this.frictionTorque(gravity);212    let I = (2 / 5) * this.mass * Math.pow(this.raduis, 2);213    let fX, fZ, c;214    if (Math.abs(this.angular_velocity.z) > Math.abs(this.angular_velocity.x)) {215      c =216        Math.abs(this.angular_velocity._x) /217        Math.abs(this.angular_velocity._z + this.angular_velocity._x);218      fX = friction * c;219      fZ = friction * (1 - c);220    } else {221      c =222        Math.abs(this.angular_velocity._z) /223        Math.abs(this.angular_velocity._z + this.angular_velocity._x);224      fZ = friction * c;225      fX = friction * (1 - c);226    }227    let result = vector.create(228      Number((-windForce._z * this.raduis * 2).toFixed(2)),229      0,230      Number((windForce._x * this.raduis * 2).toFixed(2))231    );232    if (this.angular_velocity._z > 0) {233      result._z -= fZ;234    } else {235      result._z += fZ;236    }237    if (this.angular_velocity._x > 0) {238      result._x -= Math.abs(fX);239    } else {240      result._x += Math.abs(fX);241    }242    result.divideBy(I);243    if (244      Math.abs(this.angular_velocity._x) < 1 &&245      Math.abs(this.angular_velocity._z) < 1246    ) {247      this.angular_velocity._y = 0;248      this.angular_velocity._z = 0;249      this.angular_velocity._x = 0;250    }251    return result;252  }253  updateQuaternion(vector, time) {254    const quaternionTemp = new THREE.Quaternion(255      vector._x * time,256      vector._y * time,257      vector._z * time,258      0259    );260    quaternionTemp.multiply(this.quaternion);261    this.quaternion.x += quaternionTemp.x * 0.5;262    this.quaternion.y += quaternionTemp.y * 0.5;263    this.quaternion.z += quaternionTemp.z * 0.5;264    this.quaternion.w += quaternionTemp.w * 0.5;265  }266  updateRotationMatrix(quaternion) {267    const q = quaternion;268    this.rotationMatrix.set(269      1 - 2 * Math.pow(q.y, 2) - 2 * Math.pow(q.z, 2),270      2 * q.x * q.y - 2 * q.z * q.w,271      2 * q.x * q.z + 2 * q.y * q.w,272      2 * q.x * q.y + 2 * q.z * q.w,273      1 - 2 * Math.pow(q.x, 2) - 2 * Math.pow(q.z, 2),274      2 * q.y * q.z - 2 * q.x * q.w,275      2 * q.x * q.z - 2 * q.y * q.w,276      2 * q.y * q.z + 2 * q.x * q.w,277      1 - 2 * Math.pow(q.x, 2) - 2 * Math.pow(q.y, 2)278    );279  }280  bouncing() {281    let ground = 3.0;282    if (this.raduis > 4.5) ground = 19.0;283    else if (this.raduis > 4) ground = 17.0;284    else if (this.raduis > 3.5) ground = 14.0;285    else if (this.raduis > 3) ground = 13.0;286    else if (this.raduis > 2.5) ground = 12.0;287    else if (this.raduis > 2) ground = 10.0;288    else if (this.raduis > 1.5) ground = 8.0;289    else if (this.raduis > 1) ground = 6.0;290    else if (this.raduis > 0.7) ground = 5.0;291    if (this.position.y < ground) {292      let veloCopy = this.velocity.clone();293      this.position.y = ground;294      this.velocity._y *= -this.resistanse_coeff;295      this.angular_velocity._y *= -this.resistanse_coeff;296      let costum = Math.sqrt(297        veloCopy._x * veloCopy._x + veloCopy._z * veloCopy._z298      );299      //Rolling Condition300      if (0.17 > this.velocity._y / costum) {301        this.velocity._y = 0;302        if (!this.rolling) {303          this.angular_velocity._z = -1 * veloCopy._x;304          this.angular_velocity._x = -1 * veloCopy._z;305        }306        this.rolling = true;307      } else {308        this.rolling = false;309        this.velocity._x =310          0.6 * this.velocity._x - 0.4 * this.angular_velocity._z * this.raduis;311        this.velocity._z =312          0.6 * this.velocity._z - 0.4 * this.angular_velocity._x * this.raduis;313        this.angular_velocity._z =314          -1 *315          (0.4 * this.angular_velocity._z + (0.6 * veloCopy._x) / this.raduis);316        this.angular_velocity._x =317          -1 *318          (0.4 * this.angular_velocity._x + (0.6 * veloCopy._z) / this.raduis);319      }320    }321  }322  fraction(object) {323    let tempArray = this.intersectsObjects.filter(324      (element) => element === object.object325    );326    if (!tempArray.length) {327      this.intersectsObjects.push(object.object);328      let normal = object.face.normal;329      if (330        (normal.x >= normal.z || normal.x <= normal.z) &&331        Math.fround(normal.y) <= 0332      ) {333        this.velocity._z *= this.resistanse_coeff;334        this.angular_velocity._x *= this.resistanse_coeff;335        this.velocity._z =336          -(0.6 * this.velocity._z) -337          0.4 * this.angular_velocity._x * this.raduis;338        this.angular_velocity._x =339          -1 *340          (0.4 * this.angular_velocity._x +341            (0.6 * this.velocity._z) / this.raduis);342      } else {343        this.velocity._x *= this.resistanse_coeff;344        this.angular_velocity._z *= this.resistanse_coeff;345        this.velocity._x =346          -(0.6 * this.velocity._x) -347          0.4 * this.angular_velocity._z * this.raduis;348        this.angular_velocity._z =349          -1 *350          (0.4 * this.angular_velocity._z +351            (0.6 * this.velocity._x) / this.raduis);352      }353    }354  }355}...magic-eye-generator.js
Source:magic-eye-generator.js  
...319			camera.right = rotateAround(camera.right, [0, 1, 0], d * turnSpeed);320			camera.up = rotateAround(camera.up, [0, 1, 0], d * turnSpeed);321		}322		if (pressedControls.turnUp) {323			let [a, b] = rotateAxes(camera.up, camera.dir, -d * turnSpeed)324			camera.up = a;325			camera.dir = b;326		}327		if (pressedControls.turnDown) {328			let [a, b] = rotateAxes(camera.dir, camera.up, -d * turnSpeed)329			camera.dir = a;330			camera.up = b;331		}332		333		334		render();335		336	}337	338	prevTime = t;339	340	requestAnimationFrame(renderLoop);341}342function rotateAxes(a, b, angle) {343	angle *= Math.PI/180;344	return [345		v3.add(v3.mulScalar(a, Math.cos(angle)), v3.mulScalar(b, Math.sin(angle))),346		v3.add(v3.mulScalar(b, Math.cos(angle)), v3.mulScalar(a, -Math.sin(angle)))347	];348}349function rotateAround(v, axis, angle) {350	angle *= Math.PI/180;351	352	let alignedPart = vecProj(v, axis),353		rotatePart = v3.subtract(v, alignedPart),354		rotateTarget = v3.cross(axis, rotatePart);355	356	return v3.add(v3.add(alignedPart, v3.mulScalar(rotatePart, Math.cos(angle))), v3.mulScalar(rotateTarget, Math.sin(angle)));...camera.js
Source:camera.js  
...117    var x = horizontal;118    horizontal = x * Math.cos(angle) - 2 * vertical * Math.sin(angle);119    vertical = x * Math.sin(angle) / 2 + vertical * Math.cos(angle);120  }121  rotateAxes(this.roll_);122  vertical /= Math.max(Math.abs(Math.cos(this.tilt_)), 0.1);123  rotateAxes(this.heading_);124  this.setPosition(this.latitude_ + vertical, this.longitude_ + horizontal);125};126/**127 * Rotates the camera around fixed point128 * @param {number} latitude Latitude of fixed point in radians.129 * @param {number} longitude Longitude of fixed point in radians.130 * @param {number} distance Distance of camera from the rotation point.131 * @param {number} horizontalAngle Angle in radians.132 * @param {number} verticalAngle Angle in radians.133 */134we.scene.Camera.prototype.rotateAround = function(latitude, longitude, distance,135                                                  horizontalAngle,136                                                  verticalAngle) {137  this.heading_ += horizontalAngle;...status-indicator.js
Source:status-indicator.js  
...151        this.canvasContext.translate(-this.spinnerCenter, -this.spinnerCenter);152    }153    _getRotatedGradientPoints (point) {154        let changedPoint = moveAxes(point, this.spinnerCenter);155        changedPoint = rotateAxes(changedPoint, this.rotationAngle);156        changedPoint = moveAxes(changedPoint, -this.spinnerCenter);157        return changedPoint;158    }159    _setSpinnerGradient () {160        let startGradientPoint = {161            x: Math.round(this.size * START_GRADIENT_POINT_OFFSET.x),162            y: Math.round(this.size * START_GRADIENT_POINT_OFFSET.y)163        };164        let endGradientPoint = {165            x: Math.round(this.size * END_GRADIENT_POINT_OFFSET.x),166            y: Math.round(this.size * END_GRADIENT_POINT_OFFSET.y)167        };168        if (this.rotationAngle !== 0) {169            startGradientPoint = this._getRotatedGradientPoints(startGradientPoint);...gltfWorker.js
Source:gltfWorker.js  
...56	}57	geometry.setAttribute( 'uv', uvs );58	const material = new MeshStandardMaterial( { map: new Texture( gradient ) } );59	if ( options.rotate ) {60		rotateAxes( vertices );61	}62	return new Mesh( geometry, material );63}64function getLines( item, options ) {65	const geometry = new BufferGeometry();66	geometry.setIndex( item.index );67	geometry.setAttribute( 'position', item.position );68	const material = new MeshStandardMaterial();69	if ( options.rotate ) {70		rotateAxes( item.position.array );71	}72	return new LineSegments( geometry, material );73}74function rotateAxes( vertices ) {75	const vertexCount = vertices.length;76	// rotate axes for z up.77	for ( let i = 0; i < vertexCount; i++ ) {78		const v = i * 3;79		const z = vertices[ v + 2 ];80		vertices[ v + 2 ] = -vertices[ v + 1 ]; // z = -y81		vertices[ v + 1 ] = z; // y = z82	}...CameraView.js
Source:CameraView.js  
...25    transitionTime = transitionTime || 1;26    transitionFunc = transitionFunc || "ease-out";27    this.$el.children().detach();28    this.$el.append(this.dollyView.render().el);29    this.$el.css("-webkit-transform", rotateAxes(this.xyzRot[0],this.xyzRot[1],this.xyzRot[2]));30    this.$el.css("-webkit-transition-timing-function",transitionFunc);31    this.$el.css("-webkit-transitionDuration",transitionTime+"s");32    return this;33  },34  hover: function(){35  },36  unhover: function(){37  },38  handleKeyInput: function(e){39    var ROTATION_DEG = 5;40    var DURATION = 1;41    var currentRotation;42    switch (e.keyCode){43      case 37: //left44        this.dollyView.move(-50,0,0);45      break;46      case 39: //right47        this.dollyView.move(50,0,0);48      break;49      case 38: //up50        this.dollyView.move(0,-50,0);51      break;52      case 40: //down53        this.dollyView.move(0,50,0);54      break;55      case 219://left bracket56        this.xyzRot[1] = Math.min(this.xyzRot[1] + ROTATION_DEG,45);57      break;58      case 221://right bracket59        this.xyzRot[1] = Math.max(this.xyzRot[1] - ROTATION_DEG,-45);60      break;61      case 187: //plus62        this.dollyView.move(0,0,100);63      break;64      case 189: //minus65        this.dollyView.move(0,0,-100);66      break;67    }68    this.$el.css("-webkit-transform", rotateAxes(this.xyzRot[0],this.xyzRot[1],this.xyzRot[2]));69    this.$el.css("-webkit-transition-timing-function","ease-out");70    this.$el.css("-webkit-transitionDuration",DURATION+"s");71  },72  focusOnCoordinates: function(coords){73    this.dollyView.centerOnCoords(coords[0],coords[1],coords[2]);74  }...Helpers.js
Source:Helpers.js  
1var translate3d = function(x, y, z){2  return "translate3d(" + x + "px, " + y + "px, " + z + "px)";3};4var rotateAxis = function(axis, degree){5  return "rotate"+axis+"("+degree+"deg)";6};7var offsetIndex = function(n){8  if(n%2 === 0){9    return -n || -1;10  }else{11    return n;12  }13};14var rotateAxes = function(x, y, z){15  return "rotateX(" + x + "deg) " + "rotateY(" + y + "deg) " + "rotateZ(" + z + "deg)";16};17var generateSVGPath = function (x1,y1,x2,y2,center){18  var xCtrl,19      yCtrl;20  xCtrl = Math.floor((x2+x1)*0.50);21  yCtrl = Math.floor((y1+y2)*0.35);22  center = center || 0;23  var newLine = document.createElementNS('http://www.w3.org/2000/svg','line');24  newLine.setAttribute("x1",""+(x1+center));25  newLine.setAttribute("x2",""+(x2+center));26  newLine.setAttribute("y1",""+y1);27  newLine.setAttribute("y2",""+y2);28  newLine.setAttribute("stroke-width","2");29  newLine.setAttribute("stroke","gray");30  return newLine;31};32var updateTreeDepth = function(hierarchyData){33  var getMaxDepthofChildren  = function(nodeID,curDepth){34    var children = hierarchyData.get(nodeID).children;35    var childDepths = [];36    curDepth = curDepth || 1;37    if(children && children.length >= 0){38      for(var i = 0; i < children.length; i++){39        childDepths.push(getMaxDepthofChildren(children[i],curDepth+1));40      }41    }42    //return the greatest of each child path43    var greatestChild = 0;44    for(var j = 0; j < childDepths.length; j++){45      if(childDepths[j] > greatestChild){46        greatestChild = childDepths[j];47      }48    }49    if(curDepth > greatestChild){50      return curDepth;51    } else {52      return greatestChild;53    }54  };55  return getMaxDepthofChildren(1,0);...main.js
Source:main.js  
1const triangleLeft = document.querySelector('.triangleLeft')2const triangleBottom = document.querySelector('.triangleBottom')3let rotateDeg = 180;4function rotateAxes(obj, deg) {5    obj.style.transform = `rotate(${deg}deg)`6}7setInterval(function () {8    rotateAxes(triangleLeft, rotateDeg)9    setTimeout(function () {10        rotateAxes(triangleBottom, rotateDeg)11        rotateDeg += 18012    }, 600)...Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#tried-test-cafe')5        .click(Selector('label').withText('I have tried TestCafe'))6        .click('#submit-button');7});8test('My first test', async t => {9        .click('#populate')10        .click('#submit-button');11});12const articleHeader = await Selector('.result-content').find('h1');13const headerText = await articleHeader.innerText;14await t.expect(headerText).eql('Thank you, John Smith!');Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#macos')5        .click('#submit-button');6});7import { Selector } from 'testcafe';8test('My first test', async t => {9        .typeText('#developer-name', 'John Smith')10        .click('#macos')11        .click('#submit-button');12});13import { Selector } from 'testcafe';14test('My first test', async t => {15        .rotateAxes(true, 90)16        .typeText('#developer-name', 'John Smith')17        .click('#macos')18        .click('#submit-button');19});Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});Using AI Code Generation
1import {Selector} from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .wait(3000)6        .rotateAxes(Selector('#submit-button'), 10, 20);7});8test('My first test', async t => {9        .typeText('#developer-name', 'John Smith')10        .click('#submit-button')11        .wait(3000)12        .rotateAxes(null, 10, 20);13});14rotateToOrientation(orientation)15import {Selector} from 'testcafe';16test('My first test', async t => {17        .typeText('#developer-name', 'John Smith')18        .click('#submit-button')19        .wait(3000)20        .rotateToOrientation(90);21});22takeElementScreenshot(selector, path [, options])Using AI Code Generation
1import { Selector } from 'testcafe';2const testControllerHolder = {};3test('My first test', async t => {4    testControllerHolder.t = t;5        .typeText('#developer-name', 'John Smith')6        .click('#submit-button');7    await rotateAxes(testControllerHolder, 0, 0);8});9async function rotateAxes(testControllerHolder, x, y) {10    await testControllerHolder.t.eval(() => {11        return new Promise(resolve => {12                .click(0, 0)13                .then(() => window.testCafeDriver14                    .drag(100, 0)15                    .then(() => window.testCafeDriver16                        .drag(100, 100)17                        .then(() => window.testCafeDriver18                            .drag(0, 100)19                            .then(() => window.testCafeDriver20                                .drag(0, 0)21                                .then(() => resolve())22                );23        });24    }, { dependencies: { x, y } });25}Using AI Code Generation
1import { Selector } from 'testcafe';2test('My Test', async t => {3    const select = Selector('#preferred-interface');4    const option = select.find('option');5        .click(select)6        .click(option.withText('Both'))7        .expect(select.value).eql('Both');8});9test('My Test', async t => {10    const select = Selector('#preferred-interface');11    const option = select.find('option');12        .click(select)13        .click(option.withText('Both').rotateAxes())14        .expect(select.value).eql('Both');15});16test('My Test', async t => {17    const select = Selector('#preferred-interface');18    const option = select.find('option');19        .click(select)20        .click(option.withText('Both').rotateAxes(2))21        .expect(select.value).eql('Both');22});23test('My Test', async t => {24    const select = Selector('#preferred-interface');25    const option = select.find('option');26        .click(select)27        .click(option.withText('Both').rotateAxes(3))28        .expect(select.value).eql('Both');29});30test('My Test', async t => {31    const select = Selector('#preferred-interface');32    const option = select.find('option');33        .click(select)34        .click(option.withText('Both').rotateAxes(4))35        .expect(select.value).eql('Both');36});37test('My Test', async t => {38    const select = Selector('#preferred-interface');39    const option = select.find('option');40        .click(select)41        .click(option.withText('Both').rotateAxes(5))42        .expect(select.value).eql('Both');43});44test('My Test', async t => {Using AI Code Generation
1import { Selector } from 'testcafe';2import { rotateAxes } from 'testcafe-browser-provider-electron';3test('My first test', async t => {4        .typeText('#developer-name', 'John Smith')5        .click('#submit-button')6        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');7});8test('My second test', async t => {9        .click(rotateAxes('#submit-button', 90))10        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');11});12 - Electron 5.0.0 (headless)13      Browser: Electron 5.0.0 (headless)14         1 | import { Selector } from 'testcafe';15         2 | import { rotateAxes } from 'testcafe-browser-provider-electron';16         7 | test('My first test', async t => {17         9 |         .typeText('#developer-name', 'John Smith')18        10 |         .click('#submit-button')19        11 |         .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');20        12 | });21        14 | test('My second test', async t => {22        16 |         .click(rotateAxes('#submit-button', 90))23        17 |         .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');24        18 | });Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .wait(5000)6        .rotateAxes(90)7        .wait(5000)8        .rotateAxes(-90)9        .wait(5000)10        .rotateAxes(180)11        .wait(5000)12        .rotateAxes(-180)13        .wait(5000)14        .rotateAxes(270)15        .wait(5000)16        .rotateAxes(-270)17        .wait(5000);18});19const createTestCafe = require('testcafe');20const customReporter = require('testcafe-reporter-custom');21let testcafe = null;22createTestCafe('localhost', 1337, 1338)23    .then(tc => {24        testcafe = tc;25        const runner = testcafe.createRunner();26            .src('test.js')27            .browsers('chrome')28            .reporter(customReporter)29            .run();30    })31    .then(failedCount => {32        console.log('Tests failed: ' + failedCount);33        testcafe.close();34    });Using AI Code Generation
1import {Selector} from 'testcafe';2fixture('My fixture')3test('My test', async t => {4        .click('#tried-test-cafe')5        .click(Selector('label').withText('I have tried TestCafe'))6        .click('#tried-test-cafe')7        .click(Selector('label').withText('I have tried TestCafe'))8        .click('#tried-test-cafe')9        .click(Selector('label').withText('I have tried TestCafe'))10        .click('#tried-test-cafe')11        .click(Selector('label').withText('I have tried TestCafe'))12        .click('#tried-test-cafe')13        .click(Selector('label').withText('I have tried TestCafe'))14        .click('#tried-test-cafe')15        .click(Selector('label').withText('I have tried TestCafe'))16        .click('#tried-test-cafe')17        .click(Selector('label').withText('I have tried TestCafe'))18        .click('#tried-test-cafe')19        .click(Selector('label').withText('I have tried TestCafe'))20        .click('#tried-test-cafe')21        .click(Selector('label').withText('I have tried TestCafe'))22        .click('#tried-test-cafe')23        .click(Selector('label').withText('I have tried TestCafe'))24        .click('#tried-test-cafe')25        .click(Selector('label').withText('I have tried TestCafe'))26        .click('#tried-test-cafe')27        .click(Selector('label').withText('I have tried TestCafe'));28});29import {Selector} from 'testcafe';30fixture('My fixture')31test('My test', async t => {32        .click('#tried-test-cafe')33        .click(Selector('label').withText('I have tried TestCafe'))34        .click('#tried-test-cafe')35        .click(Selector('label').withText('I have tried TestCUsing AI Code Generation
1import {Selector} from 'testcafe';2const selector = Selector('div');3test('My Test', async t => {4        .click(selector.rotateAxes(90));5});6import {Selector} from 'testcafe';7const selector = Selector('div');8test('My Test', async t => {9        .click(selector.rotateAxes(90));10});11{12  "scripts": {13  },14  "dependencies": {15  }16}Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
