How to use test_frame_name method in Playwright Python

Best Python code snippet using playwright-python

multibody_plant_subgraph_test_helpers.py

Source:multibody_plant_subgraph_test_helpers.py Github

copy

Full Screen

1"""2Helpers for test code.3"""4from collections import defaultdict5import random6import numpy as np7from numpy.testing import assert_array_equal8from pydrake.geometry import Box, GeometryInstance, HalfSpace9from pydrake.math import RigidTransform10from pydrake.multibody.plant import CoulombFriction11from pydrake.multibody.tree import (12 BallRpyJoint,13 FixedOffsetFrame,14 PrismaticJoint,15 RevoluteJoint,16 SpatialInertia,17 UnitInertia,18 UniversalJoint,19 WeldJoint,20)21from pydrake.systems.primitives import ConstantVectorSource22from multibody_plant_prototypes.containers import strict_zip23from .. import multibody_extras as me24from .. import multibody_plant_subgraph as mut25JOINT_CLS_LIST = [26 PrismaticJoint,27 RevoluteJoint,28 BallRpyJoint,29 UniversalJoint,30 WeldJoint,31]32def build_with_no_control(builder, plant, model):33 """Connects a zero-torque input to a given model instance in a plant."""34 # TODO(eric.cousineau): Use `multibody_plant_prototypes.control` if the dependency can35 # be simplified.36 nu = plant.num_actuated_dofs(model)37 constant = builder.AddSystem(ConstantVectorSource(np.zeros(nu)))38 builder.Connect(39 constant.get_output_port(0),40 plant.get_actuation_input_port(model))41def compare_frame_poses(42 plant, context, sub_plant, sub_context,43 base_frame_name, test_frame_name, **kwargs):44 """Compares the poses of two frames."""45 X_BT_sub = sub_plant.CalcRelativeTransform(46 sub_context,47 sub_plant.GetFrameByName(base_frame_name),48 sub_plant.GetFrameByName(test_frame_name))49 X_BT = plant.CalcRelativeTransform(50 context,51 plant.GetFrameByName(base_frame_name, **kwargs),52 plant.GetFrameByName(test_frame_name, **kwargs))53 np.testing.assert_allclose(54 X_BT_sub.GetAsMatrix4(),55 X_BT.GetAsMatrix4(), rtol=0., atol=1e-10)56def add_arbitrary_multibody_stuff(57 plant, num_bodies=30, slight_difference=False):58 """59 Deterministic, physically valid, jumble of arbitrary stuff.60 The goal of this factory is to:61 - Produce a set of elements and cases that exercise each code path in62 `MultibodyPlantSubgraph.add_to` and `MultibodyPlantElementsMap`.63 - Ensure each element has somewhat "random" but unique properties for each64 element produced.65 - Allow for a slight difference to show that strict plant comparison can be66 falsified.67 """68 count = defaultdict(lambda: 0)69 def i_next(key=None):70 # Increments for a given key.71 count[key] += 172 return count[key]73 def maybe():74 # Returns True or False randomly.75 return random.choice([True, False])76 def random_model_instance():77 # Returns a "random" model instance (by incrementing).78 i = i_next()79 return plant.AddModelInstance(f"model_{i}")80 def random_position():81 # Returns a random position.82 return [0.2 * random.random(), 0, 0]83 def random_X():84 # Returns a random pose.85 return RigidTransform(random_position())86 def random_body():87 # Returns a random body, with an incrementing name.88 inertia = SpatialInertia(89 mass=random.uniform(0.2, 1.),90 p_PScm_E=random_position(),91 G_SP_E=UnitInertia(92 Ixx=random.uniform(0.2, 0.3),93 Iyy=random.uniform(0.2, 0.3),94 Izz=random.uniform(0.2, 0.3),95 ),96 )97 return plant.AddRigidBody(98 name=f"body_{i_next()}",99 M_BBo_B=inertia,100 model_instance=random_model_instance(),101 )102 def random_frame(parent_frame):103 # Returns a random frame, with an incrementing name.104 i = i_next()105 return plant.AddFrame(FixedOffsetFrame(106 name=f"frame_{i}", P=parent_frame,107 X_PF=random_X(),108 model_instance=parent_frame.model_instance(),109 ))110 def random_joint(parent, child):111 # Returns a random joint, but with an incrementing name. Note that we112 # use a separate index so that we ensure we can loop through all113 # joints.114 i = i_next("joint")115 name = f"joint_{i}"116 joint_cls = JOINT_CLS_LIST[i % len(JOINT_CLS_LIST)]117 frame_on_parent = random_frame(parent.body_frame())118 frame_on_child = random_frame(child.body_frame())119 axis = np.zeros(3)120 axis[i_next() % 3] = 1121 damping = random.random()122 if joint_cls == BallRpyJoint:123 joint = BallRpyJoint(124 name,125 frame_on_parent=frame_on_parent,126 frame_on_child=frame_on_child,127 damping=damping,128 )129 elif joint_cls == PrismaticJoint:130 joint = PrismaticJoint(131 name,132 frame_on_parent=frame_on_parent,133 frame_on_child=frame_on_child,134 axis=axis,135 damping=damping,136 )137 elif joint_cls == RevoluteJoint:138 joint = RevoluteJoint(139 name,140 frame_on_parent=frame_on_parent,141 frame_on_child=frame_on_child,142 axis=axis,143 damping=damping,144 )145 elif joint_cls == UniversalJoint:146 joint = UniversalJoint(147 name,148 frame_on_parent=frame_on_parent,149 frame_on_child=frame_on_child,150 damping=damping,151 )152 elif joint_cls == WeldJoint:153 joint = WeldJoint(154 name,155 frame_on_parent_P=frame_on_parent,156 frame_on_child_C=frame_on_child,157 X_PC=random_X(),158 )159 else:160 assert False161 return plant.AddJoint(joint)162 def random_joint_actuator(joint):163 # Creates a random joint actuator.164 assert joint is not None165 i = i_next()166 return plant.AddJointActuator(167 f"actuator_{i}", joint, effort_limit=random.uniform(1, 2))168 def random_geometry(body):169 # Creates a random geometry.170 i = i_next()171 box = Box(172 width=random.uniform(0.1, 0.3),173 depth=random.uniform(0.1, 0.3),174 height=random.uniform(0.1, 0.3),175 )176 plant.RegisterVisualGeometry(177 body=body,178 X_BG=random_X(),179 shape=box,180 name=f"visual_{i}",181 diffuse_color=[random.random(), 0, 0, 0.75],182 )183 static_friction = random.uniform(0.1, 1.)184 plant.RegisterCollisionGeometry(185 body=body,186 X_BG=random_X(),187 shape=box,188 name=f"collision_{i}",189 coulomb_friction=CoulombFriction(190 static_friction=static_friction,191 dynamic_friction=static_friction / 2,192 )193 )194 # Add ground plane.195 X_FH = HalfSpace.MakePose([0, 0, 1], [0, 0, 0])196 plant.RegisterCollisionGeometry(197 plant.world_body(), X_FH, HalfSpace(), "ground_plane_collision",198 CoulombFriction(0.8, 0.3))199 grid_rows = 5200 prev_body = None201 for i in range(num_bodies):202 random.seed(i)203 body = random_body()204 grid_col = i % grid_rows205 grid_row = int(i / grid_rows)206 if slight_difference:207 grid_row += 1208 plant.SetDefaultFreeBodyPose(209 body, RigidTransform([grid_col, grid_row, 2]))210 random_frame(body.body_frame())211 # Consider attaching a joint and/or frame to the world.212 if maybe() or num_bodies < 3:213 prev_body = plant.world_body()214 random_frame(plant.world_frame())215 if prev_body is not None and (maybe() or num_bodies < 3):216 joint = random_joint(prev_body, body)217 if joint.num_velocities() == 1 and (maybe() or num_bodies < 3):218 random_joint_actuator(joint)219 if plant.geometry_source_is_registered():220 random_geometry(body)221 prev_body = body222def assert_inertia_equals(a, b):223 assert_array_equal(a.CopyToFullMatrix6(), b.CopyToFullMatrix6())224def assert_pose_equals(a, b):225 assert_array_equal(a.GetAsMatrix4(), b.GetAsMatrix4())226def check_element(a, b, check_index=True):227 """Checks that two multibody elements have similar base properties."""228 assert a is not b229 if check_index:230 assert a.index() == b.index()231 assert a.name() == b.name(), (a.name(), b.name())232 assert type(a) == type(b)233 assert a.model_instance() == b.model_instance()234def assert_shape_equals(a, b):235 assert type(a) == type(b)236 if type(a) == Box:237 assert a.width() == b.width()238 assert a.height() == b.height()239 assert a.depth() == b.depth()240 elif type(a) == HalfSpace:241 pass242 else:243 assert False244def assert_value_equals(value_a, value_b):245 a = value_a.get_value()246 b = value_b.get_value()247 assert type(a) == type(b)248 if type(a) == CoulombFriction:249 assert a.static_friction() == b.static_friction()250 assert a.dynamic_friction() == b.dynamic_friction()251 else:252 assert a == b253def assert_properties_equals(prop_a, prop_b):254 if prop_a is None:255 assert prop_b is None256 return257 groups = prop_a.GetGroupNames()258 assert groups == prop_b.GetGroupNames()259 for group_name in groups:260 group_a = prop_a.GetPropertiesInGroup(group_name)261 group_b = prop_b.GetPropertiesInGroup(group_name)262 assert len(group_a) == len(group_b)263 for name, value_a in group_a.items():264 value_b = group_b[name]265 try:266 assert_value_equals(value_a, value_b)267 except RuntimeError as e:268 if "AddValueInstantiation" in str(e):269 # TODO(eric.cosuineau): Fix this stuff for Vector4d.270 assert (group_name, name) == ("phong", "diffuse")271 else:272 raise273def assert_plant_equals(plant_a, scene_graph_a, plant_b, scene_graph_b):274 """275 Asserts that two plants are (almost) completely equal; more specifically:276 - All model instances, bodies, joints, and joint actuators have the same277 indices.278 - Frames may have different indices, due to ordering.279 - All properties of each element are "exactly" the same.280 """281 assert plant_a is not plant_b282 if scene_graph_b is not None:283 assert scene_graph_a is not None284 elem_a = mut.get_elements_from_plant(plant_a, scene_graph_a)285 checked_a = mut.MultibodyPlantElements(plant_a, scene_graph_a)286 elem_b = mut.get_elements_from_plant(plant_b, scene_graph_b)287 checked_b = mut.MultibodyPlantElements(plant_b, scene_graph_b)288 def assert_body_equals(body_a, body_b):289 check_element(body_a, body_b)290 assert_inertia_equals(291 body_a.default_spatial_inertia(), body_b.default_spatial_inertia())292 assert body_a.model_instance() in checked_a.model_instances293 assert body_b.model_instance() in checked_b.model_instances294 assert_pose_equals(295 plant_a.GetDefaultFreeBodyPose(body_a),296 plant_b.GetDefaultFreeBodyPose(body_b))297 checked_a.bodies.add(body_a)298 checked_b.bodies.add(body_b)299 def assert_frame_equals(frame_a, frame_b):300 check_element(frame_a, frame_b, check_index=False)301 assert frame_a.body() in checked_a.bodies302 assert frame_b.body() in checked_b.bodies303 assert_pose_equals(304 frame_a.GetFixedPoseInBodyFrame(),305 frame_b.GetFixedPoseInBodyFrame())306 checked_a.frames.add(frame_a)307 checked_b.frames.add(frame_b)308 def assert_joint_equals(joint_a, joint_b):309 check_element(joint_a, joint_b)310 assert joint_a.frame_on_parent() in checked_a.frames311 assert joint_b.frame_on_parent() in checked_b.frames312 assert joint_a.frame_on_child() in checked_a.frames313 assert joint_b.frame_on_child() in checked_b.frames314 assert_array_equal(315 joint_a.position_lower_limits(),316 joint_b.position_lower_limits())317 assert_array_equal(318 joint_a.position_upper_limits(),319 joint_b.position_upper_limits())320 assert_array_equal(321 joint_a.velocity_upper_limits(),322 joint_b.velocity_upper_limits())323 assert_array_equal(324 joint_a.velocity_lower_limits(),325 joint_b.velocity_lower_limits())326 assert_array_equal(327 joint_a.acceleration_lower_limits(),328 joint_b.acceleration_lower_limits())329 assert_array_equal(330 joint_a.acceleration_upper_limits(),331 joint_b.acceleration_upper_limits())332 assert_array_equal(333 joint_a.default_positions(),334 joint_b.default_positions())335 # TODO(eric.cousineau): Fix damping for BallRpyJoint.336 if type(joint_a) in [PrismaticJoint, RevoluteJoint, UniversalJoint]:337 assert joint_a.damping() == joint_b.damping()338 if type(joint_a) == PrismaticJoint:339 assert_array_equal(340 joint_a.translation_axis(),341 joint_b.translation_axis())342 if type(joint_a) == RevoluteJoint:343 assert_array_equal(344 joint_a.revolute_axis(), joint_b.revolute_axis())345 if type(joint_a) == WeldJoint:346 assert_pose_equals(joint_a.X_PC(), joint_b.X_PC())347 checked_a.joints.add(joint_a)348 checked_b.joints.add(joint_b)349 def assert_geometry_equals(a, b):350 inspector_a = scene_graph_a.model_inspector()351 body_a = plant_a.GetBodyFromFrameId(inspector_a.GetFrameId(a))352 assert body_a in checked_a.bodies353 geometry_a = inspector_a.CloneGeometryInstance(a)354 inspector_b = scene_graph_b.model_inspector()355 body_b = plant_b.GetBodyFromFrameId(inspector_b.GetFrameId(b))356 assert body_b in checked_b.bodies357 geometry_b = inspector_b.CloneGeometryInstance(b)358 assert geometry_a.name() == geometry_b.name(), (359 geometry_a.name(), geometry_b.name())360 assert_pose_equals(geometry_a.pose(), geometry_b.pose())361 assert_shape_equals(362 geometry_a.release_shape(), geometry_b.release_shape())363 prop_funcs = [364 GeometryInstance.perception_properties,365 GeometryInstance.proximity_properties,366 GeometryInstance.illustration_properties,367 ]368 for prop_func in prop_funcs:369 assert_properties_equals(370 prop_func(geometry_a), prop_func(geometry_b))371 def frame_map(frames):372 out = defaultdict(set)373 for frame in frames:374 # Some frames may not have a name :(375 key = (frame.body().name(), frame.name())376 out[key].add(frame)377 return out378 for a, b in strict_zip(elem_a.model_instances, elem_b.model_instances):379 assert a is not b380 assert a == b381 checked_a.model_instances.add(a)382 checked_b.model_instances.add(b)383 for body_a, body_b in strict_zip(elem_a.bodies, elem_b.bodies):384 assert_body_equals(body_a, body_b)385 # N.B. Because frame indices can be shifted when adding bodies, we cannot386 # trust this ordering. Instead, we need to find an identifier.387 frame_map_a = frame_map(elem_a.frames)388 frame_map_b = frame_map(elem_b.frames)389 assert len(frame_map_a) == len(frame_map_b)390 for key, frames_a in frame_map_a.items():391 frames_b = frame_map_b[key]392 for frame_a, frame_b in strict_zip(frames_a, frames_b):393 assert_frame_equals(frame_a, frame_b)394 for joint_a, joint_b in strict_zip(elem_a.joints, elem_b.joints):395 assert_joint_equals(joint_a, joint_b)396 cur_iter = strict_zip(elem_a.joint_actuators, elem_b.joint_actuators)397 for joint_actuator_a, joint_actuator_b in cur_iter:398 check_element(joint_actuator_a, joint_actuator_b)399 assert (400 joint_actuator_a.effort_limit() == joint_actuator_b.effort_limit())401 if scene_graph_b is not None:402 cur_iter = strict_zip(elem_a.geometry_ids, elem_b.geometry_ids)403 for geometry_id_a, geometry_id_b in cur_iter:...

Full Screen

Full Screen

Process_movies_argparse_tests.py

Source:Process_movies_argparse_tests.py Github

copy

Full Screen

...123 with patch('sys.argv', testargs):124 obj = m()125 self.assertEqual('1_a_{}', obj.micrograph_name) 126 127 def test_frame_name(self):128 testargs = 'foo.py -filename 1_a_###.mrc'.split()129 with patch('sys.argv', testargs):130 obj = m()131 self.assertEqual('1_a_{}_frames_n{}', obj.frame_name)132 133class test_get_file_list(unittest.TestCase):134 135 def setUp(self):136 self.testfiles = ['1_a_001_frames_n{}.mrc'.format(str(i)) \137 for i in range (7)]138 self.tempdir = tempfile.mkdtemp()139 for i in self.testfiles:140 f= open(os.path.join(self.tempdir, i), 'w')141 ...

Full Screen

Full Screen

test_frames.py

Source:test_frames.py Github

copy

Full Screen

...170 server.EMPTY_PAGE,171 )172 assert len(page.frames) == 2173 assert page.frames[1].url == server.EMPTY_PAGE174async def test_frame_name(page, server, utils):175 await utils.attach_frame(page, "theFrameId", server.EMPTY_PAGE)176 await page.evaluate(177 """url => {178 frame = document.createElement('iframe');179 frame.name = 'theFrameName';180 frame.src = url;181 document.body.appendChild(frame);182 return new Promise(x => frame.onload = x);183 }""",184 server.EMPTY_PAGE,185 )186 assert page.frames[0].name == ""187 assert page.frames[1].name == "theFrameId"188 assert page.frames[2].name == "theFrameName"...

Full Screen

Full Screen

frame_test.py

Source:frame_test.py Github

copy

Full Screen

1#!/usr/bin/env python2# Copyright Contributors to the OpenCue Project3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15"""Tests for `opencue.wrappers.frame`."""16from __future__ import print_function17from __future__ import division18from __future__ import absolute_import19import time20import unittest21import mock22from opencue.compiled_proto import depend_pb223from opencue.compiled_proto import job_pb224import opencue.wrappers.frame25import opencue.wrappers.job26import opencue.wrappers.layer27TEST_FRAME_NAME = 'testFrame'28@mock.patch('opencue.cuebot.Cuebot.getStub')29class FrameTests(unittest.TestCase):30 def testEat(self, getStubMock):31 stubMock = mock.Mock()32 stubMock.Eat.return_value = job_pb2.FrameEatResponse()33 getStubMock.return_value = stubMock34 frame = opencue.wrappers.frame.Frame(35 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.WAITING))36 frame.eat()37 stubMock.Eat.assert_called_with(38 job_pb2.FrameEatRequest(frame=frame.data), timeout=mock.ANY)39 def testKill(self, getStubMock):40 stubMock = mock.Mock()41 stubMock.Kill.return_value = job_pb2.FrameKillResponse()42 getStubMock.return_value = stubMock43 frame = opencue.wrappers.frame.Frame(44 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))45 frame.kill()46 stubMock.Kill.assert_called_with(47 job_pb2.FrameKillRequest(frame=frame.data), timeout=mock.ANY)48 def testRetry(self, getStubMock):49 stubMock = mock.Mock()50 stubMock.Retry.return_value = job_pb2.FrameRetryResponse()51 getStubMock.return_value = stubMock52 frame = opencue.wrappers.frame.Frame(53 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))54 frame.retry()55 stubMock.Retry.assert_called_with(56 job_pb2.FrameRetryRequest(frame=frame.data), timeout=mock.ANY)57 def testGetWhatDependsOnThis(self, getStubMock):58 dependId = 'ddd-dddd-ddd'59 stubMock = mock.Mock()60 stubMock.GetWhatDependsOnThis.return_value = job_pb2.FrameGetWhatDependsOnThisResponse(61 depends=depend_pb2.DependSeq(depends=[depend_pb2.Depend(id=dependId)]))62 getStubMock.return_value = stubMock63 frame = opencue.wrappers.frame.Frame(64 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))65 depends = frame.getWhatDependsOnThis()66 stubMock.GetWhatDependsOnThis.assert_called_with(67 job_pb2.FrameGetWhatDependsOnThisRequest(frame=frame.data), timeout=mock.ANY)68 self.assertEqual(len(depends), 1)69 self.assertEqual(depends[0].id(), dependId)70 def testGetWhatThisDependsOn(self, getStubMock):71 dependId = 'ddd-dddd-ddd'72 stubMock = mock.Mock()73 stubMock.GetWhatThisDependsOn.return_value = job_pb2.FrameGetWhatThisDependsOnResponse(74 depends=depend_pb2.DependSeq(depends=[depend_pb2.Depend(id=dependId)]))75 getStubMock.return_value = stubMock76 frame = opencue.wrappers.frame.Frame(77 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))78 depends = frame.getWhatThisDependsOn()79 stubMock.GetWhatThisDependsOn.assert_called_with(80 job_pb2.FrameGetWhatThisDependsOnRequest(frame=frame.data), timeout=mock.ANY)81 self.assertEqual(len(depends), 1)82 self.assertEqual(depends[0].id(), dependId)83 def testCreateDependencyOnFrame(self, getStubMock):84 dependId = 'ddd-dddd-ddd'85 stubMock = mock.Mock()86 stubMock.CreateDependencyOnFrame.return_value = \87 job_pb2.FrameCreateDependencyOnFrameResponse(depend=depend_pb2.Depend(id=dependId))88 getStubMock.return_value = stubMock89 dependFrameName = 'frameDependTest'90 frame = opencue.wrappers.frame.Frame(91 job_pb2.Frame(name=TEST_FRAME_NAME))92 dependOnFrame = opencue.wrappers.frame.Frame(93 job_pb2.Frame(name=dependFrameName))94 depend = frame.createDependencyOnFrame(dependOnFrame)95 stubMock.CreateDependencyOnFrame.assert_called_with(96 job_pb2.FrameCreateDependencyOnFrameRequest(frame=frame.data,97 depend_on_frame=dependOnFrame.data),98 timeout=mock.ANY)99 self.assertEqual(depend.id(), dependId)100 def testCreateDependencyOnJob(self, getStubMock):101 dependId = 'ddd-dddd-ddd'102 stubMock = mock.Mock()103 stubMock.CreateDependencyOnJob.return_value = \104 job_pb2.FrameCreateDependencyOnJobResponse(depend=depend_pb2.Depend(id=dependId))105 getStubMock.return_value = stubMock106 dependJobName = 'jobDependTest'107 frame = opencue.wrappers.frame.Frame(108 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))109 dependOnJob = opencue.wrappers.job.Job(110 job_pb2.Job(name=dependJobName))111 depend = frame.createDependencyOnJob(dependOnJob)112 stubMock.CreateDependencyOnJob.assert_called_with(113 job_pb2.FrameCreateDependencyOnJobRequest(frame=frame.data, job=dependOnJob.data),114 timeout=mock.ANY)115 self.assertEqual(depend.id(), dependId)116 def testCreateDependencyOnLayer(self, getStubMock):117 dependId = 'ddd-dddd-ddd'118 stubMock = mock.Mock()119 stubMock.CreateDependencyOnLayer.return_value = \120 job_pb2.FrameCreateDependencyOnLayerResponse(depend=depend_pb2.Depend(id=dependId))121 getStubMock.return_value = stubMock122 dependLayerName = 'layerDependTest'123 frame = opencue.wrappers.frame.Frame(124 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))125 dependOnLayer = opencue.wrappers.layer.Layer(126 job_pb2.Layer(name=dependLayerName))127 depend = frame.createDependencyOnLayer(dependOnLayer)128 stubMock.CreateDependencyOnLayer.assert_called_with(129 job_pb2.FrameCreateDependencyOnLayerRequest(frame=frame.data, layer=dependOnLayer.data),130 timeout=mock.ANY)131 self.assertEqual(depend.id(), dependId)132 def testMarkAsWaiting(self, getStubMock):133 stubMock = mock.Mock()134 stubMock.MarkAsWaiting.return_value = job_pb2.FrameMarkAsWaitingResponse()135 getStubMock.return_value = stubMock136 frame = opencue.wrappers.frame.Frame(137 job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING))138 frame.markAsWaiting()139 stubMock.MarkAsWaiting.assert_called_with(140 job_pb2.FrameMarkAsWaitingRequest(frame=frame.data), timeout=mock.ANY)141 def testRunTimeZero(self, getStubMock):142 zeroFrame = opencue.wrappers.frame.Frame(143 job_pb2.Frame(name=TEST_FRAME_NAME, start_time=0, stop_time=1000))144 self.assertEqual(zeroFrame.runTime(), 0)145 def testRunTimeRunning(self, getStubMock):146 curTime = int(time.time())147 startTime = 100148 expected = curTime - startTime149 runningFrame = opencue.wrappers.frame.Frame(150 job_pb2.Frame(name=TEST_FRAME_NAME, start_time=startTime, stop_time=0))151 threshold = abs(runningFrame.runTime() - expected)152 self.assertTrue(threshold < 1)153 def testRunTimeDone(self, getStubMock):154 startTime = 100155 stopTime = 500156 expected = stopTime - startTime157 runningFrame = opencue.wrappers.frame.Frame(158 job_pb2.Frame(name=TEST_FRAME_NAME, start_time=startTime, stop_time=stopTime))159 self.assertEqual(runningFrame.runTime(), expected)160class FrameEnumTests(unittest.TestCase):161 def testCheckpointState(self):162 self.assertEqual(opencue.api.Frame.CheckpointState.DISABLED,163 opencue.compiled_proto.job_pb2.DISABLED)164 self.assertEqual(opencue.api.Frame.CheckpointState.DISABLED, 0)165 def testFrameExitStatus(self):166 self.assertEqual(opencue.api.Frame.FrameExitStatus.NO_RETRY,167 opencue.compiled_proto.job_pb2.NO_RETRY)168 self.assertEqual(opencue.api.Frame.FrameExitStatus.NO_RETRY, 256)169 def testFrameState(self):170 self.assertEqual(opencue.api.Frame.FrameState.RUNNING,171 opencue.compiled_proto.job_pb2.RUNNING)172 self.assertEqual(opencue.api.Frame.FrameState.RUNNING, 2)173if __name__ == '__main__':...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python 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