How to use test_locator method in toolium

Best Python code snippet using toolium_python

camstabilizer_tests.py

Source:camstabilizer_tests.py Github

copy

Full Screen

1#! Python2.72import unittest3from . import camstabilizer4reload(camstabilizer)5try:6 import pymel.core7except ImportError:8 pymel = None9class MayaTestScene(unittest.TestCase):10 def setUp(self):11 pymel.core.newFile(force=True)12 cube = pymel.core.polyCube()13 camaim = pymel.core.spaceLocator()14 curve = pymel.core.curve(p=[(-1.5, 0, 2),15 (-0.8, 0.5, 0.6),16 (0.1, 0, -0.8),17 (1, 0, -2.2)])18 cam, camshape = pymel.core.camera(displayResolution=True,19 displayFilmGate=False, overscan=1.8)20 cam.rename('test_camera')21 curve.rename('test_curve')22 camaim.rename('test_locator')23 cube[0].rename('test_box')24 cam.setAttr('translateZ', 5)25 cam.setParent(camaim)26 pymel.core.setKeyframe(camaim)27 pymel.core.currentTime(120, edit=True)28 camaim.setAttr('rotateY', 60)29 camaim.setAttr('rotateX', -45)30 camaim.setAttr('translateY', 5)31 camaim.setAttr('translateZ', 3)32 pymel.core.setKeyframe(camaim)33 pymel.core.lookThru('perspView', camshape)34 grp = pymel.core.group('test_curve', 'test_box')35 pymel.core.duplicate(grp)36 pymel.core.select(clear=True)37 pymel.core.setFocus('outlinerPanel1')38 def tearDown(self):39 pymel.core.select(clear=True)40 pymel.core.setFocus('outlinerPanel1')41 # pymel.core.newFile(force=True)42class CamStabilizerUnitTests(MayaTestScene):43 # @unittest.skip('already works')44 def test__CamStabilizerUnitTests__is_running(self):45 self.assertTrue(True)46 # @unittest.skip('already works')47 def test__get_selection__errors_on_empty_selection(self):48 pymel.core.select(clear=True)49 self.assertRaises(Exception, camstabilizer.get_selection)50 # @unittest.skip('already works')51 def test__get_selection__errors_on_long_or_no_selection(self):52 pymel.core.select(clear=True)53 self.assertRaises(Exception, camstabilizer.get_selection)54 pymel.core.select(clear=True)55 pymel.core.select('|group1|test_box.vtx[1:5]')56 self.assertRaises(Exception, camstabilizer.get_selection)57 pymel.core.select(clear=True)58 pymel.core.select(('|group1|test_box', 'test_camera', 'test_locator'))59 self.assertRaises(Exception, camstabilizer.get_selection)60 # @unittest.skip('already works')61 def test__get_selection__returns_selection(self):62 pymel.core.select(clear=True)63 selection = (64 ['|group1|test_box',],65 ['|group1|test_box', 'test_locator'],66 ['|group1|test_box', 'test_camera'],67 ['|group1|test_box', '|group1|test_box.vtx[1:3]'],68 ['|group1|test_box', '|group2|test_box.vtx[1:3]'],69 ['|group2|test_box',],70 ['|group2|test_box', 'test_locator'],71 ['|group2|test_box', 'test_camera'],72 ['|group2|test_box', '|group1|test_box.vtx[1:3]'],73 )74 for case in selection:75 pymel.core.select(case)76 self.assertEqual(pymel.core.selected(), camstabilizer.get_selection())77 # @unittest.skip('already works')78 def test__get_camera__returns_camera_from_panel(self):79 pymel.core.select(clear=True)80 pymel.core.select('|group1|test_box.vtx[1]')81 pymel.core.setFocus('modelPanel4')82 camtest = pymel.core.nt.Transform('test_camera')83 self.assertEqual(camstabilizer.get_camera(), camtest.getShape())84 # @unittest.skip('already works')85 def test__get_camera__returns_camera_from_selection(self):86 pymel.core.select('|group1|test_box.vtx[1]')87 pymel.core.select('test_camera', add=True)88 pymel.core.setFocus('scriptEditorPanel1')89 camtest = pymel.core.nt.Transform('test_camera')90 self.assertEqual(camstabilizer.get_camera(), camtest.getShape())91 # @unittest.skip('already works')92 def test__get_camera__errors_wihout_camera(self):93 pymel.core.select(clear=True)94 self.assertRaises(Exception, camstabilizer.get_camera)95 # @unittest.skip('already works')96 def test__get_position_object__returns_queryable_position_object(self):97 nodetypes = (98 pymel.core.nodetypes.Transform,99 pymel.core.general.MeshVertex,100 )101 selection_sets = (102 ('test_locator',),103 ('test_locator', 'test_camera',),104 )105 for selection in selection_sets:106 pymel.core.select(clear=True)107 pymel.core.select(selection)108 obj = camstabilizer.get_position_object()109 self.assertIn(type(obj), nodetypes)110 # @unittest.skip('already works')111 def test__get_position_object__errors_without_queryable_position(self):112 selection_list = (113 '|group1|test_box',114 'test_camera',115 'test_cameraShape',116 '|group1|test_box.e[2]',117 '|group1|test_box.f[2]',118 '|group1|test_curve.cv[0]',119 '|group1|test_curve.ep[0]',120 'defaultLightSet',121 'test_locator_rotateX',122 'hardwareRenderGlobals',123 'lambert1',124 '|group1|test_curve',125 )126 for sel in selection_list:127 pymel.core.select(clear=True)128 pymel.core.select(sel)129 self.assertRaises(Exception, camstabilizer.get_position_object)130 # @unittest.skip('already works')131 def test__main__exits_without_error_with_good_selection(self):132 pymel.core.select('|group2|test_box.vtx[0]')133 pymel.core.setFocus('modelPanel4')134 self.assertIsNone(camstabilizer.main(task='stabilize'))135 super(CamStabilizerUnitTests, self).setUp()136 pymel.core.select('|group2|test_box.vtx[0]', 'test_camera')137 self.assertIsNone(camstabilizer.main(task='stabilize'))138 super(CamStabilizerUnitTests, self).setUp()139 pymel.core.select('test_locator', 'test_camera')140 self.assertIsNone(camstabilizer.main(task='stabilize'))141 # @unittest.skip('already works')142 def test__stabilize__returns_transform_cam_expression_tuple(self):143 pymel.core.select('|group1|test_box.vtx[0]')144 pymel.core.setFocus('modelPanel4')145 stabilize = camstabilizer.stabilize()146 self.assertIsInstance(stabilize, tuple)147 self.assertIsInstance(stabilize[1], pymel.core.nodetypes.Camera)148 self.assertIsInstance(stabilize[2], str)149 # @unittest.skip('already works')150 def test__create_expression__returns_expression_and_node_as_tuple(self):151 cam = pymel.core.PyNode('|test_locator|test_camera|test_cameraShape')152 pos = pymel.core.PyNode('|group1|test_box|test_boxShape.vtx[3]')153 self.assertIsInstance(camstabilizer.create_expression(cam, pos), str)154 self.assertIn(cam.name(), camstabilizer.create_expression(cam, pos))155 self.assertIn(pos.name(), camstabilizer.create_expression(cam, pos))156 # @unittest.skip('already works')157 def test__setup_expression_node__errors_if_expression_exists(self):158 camstabilizer.setup_expression_node('//', 'test_cameraShape', task='create')159 self.assertRaises(Exception,160 camstabilizer.setup_expression_node,161 '//', 'test_cameraShape', task='create'162 )163 # @unittest.skip('already works')164 def test__clear_stabilizer__deletes_expression_if_exists_or_error(self):165 pymel.core.select('|group1|test_box.vtx[0]')166 pymel.core.setFocus('modelPanel4')167 cam = camstabilizer.get_camera()168 camstabilizer.main(task='stabilize')169 camstabilizer.main(task='clear')170 self.assertRaises(Exception, camstabilizer.main, task='clear')171 camstabilizer.main(task='stabilize')172 camstabilizer.main(task='clear')173 self.assertFalse(pymel.core.objExists(cam.name() + '_stabilizer'))174 camstabilizer.main(task='stabilize')175 self.assertIsNone(camstabilizer.main(task='clear'))176 # @unittest.skip('already works')177 def test__get_camera__errors_on_camera_w_offset(self):178 pymel.core.select('|group1|test_box.vtx[0]', '|test_locator|test_camera')179 cam = pymel.core.PyNode('|test_locator|test_camera|test_cameraShape')180 cam.setHorizontalFilmOffset(0.27)181 cam.setVerticalFilmOffset(-0.11)182 self.assertRaises(Exception, camstabilizer.get_camera,)183def main():184 # unittest.main(module='MayaTools.CamStabilizer.camstabilizer_tests', exit=False)...

Full Screen

Full Screen

test_target.py

Source:test_target.py Github

copy

Full Screen

1import pytest2from selenium.common.exceptions import WebDriverException3from selenium.webdriver.common.by import By4from screenpy.abilities import BrowseTheWeb5from screenpy.target import Target, TargetingError6def test_can_be_instantiated():7 t1 = Target.the("test")8 t2 = Target.the("test").located_by("test")9 assert isinstance(t1, Target)10 assert isinstance(t2, Target)11def test_complains_for_no_locator():12 """Raises if no locator was supplied."""13 target = Target.the("test")14 with pytest.raises(TargetingError):15 target.get_locator()16def test_get_locator():17 """Returns the locator tuple when asked for it"""18 css_selector = "#id"19 xpath_locator = '//div[@id="id"]'20 xpath_locator_2 = "(//a)[5]"21 css_target = Target.the("css element").located_by(css_selector)22 xpath_target = Target.the("xpath element").located_by(xpath_locator)23 xpath_target_2 = Target.the("xpath element 2").located_by(xpath_locator_2)24 assert css_target.get_locator() == (By.CSS_SELECTOR, css_selector)25 assert xpath_target.get_locator() == (By.XPATH, xpath_locator)26 assert xpath_target_2.get_locator() == (By.XPATH, xpath_locator_2)27def test_located():28 """Uses the provided locator tuple, unaltered"""29 locator = (By.ID, "spam")30 target = Target.the("test").located(locator)31 assert target.get_locator() == locator32def test_can_be_indexed():33 locator = (By.ID, "eggs")34 target = Target.the("test").located(locator)35 assert target[0] == locator[0]36 assert target[1] == locator[1]37def test_found_by(Tester):38 test_locator = (By.ID, "eggs")39 Target.the("test").located(test_locator).found_by(Tester)40 mocked_browser = Tester.ability_to(BrowseTheWeb).browser41 mocked_browser.find_element.assert_called_once_with(*test_locator)42def test_found_by_raises(Tester):43 test_name = "frobnosticator"44 mocked_browser = Tester.ability_to(BrowseTheWeb).browser45 mocked_browser.find_element.side_effect = WebDriverException46 with pytest.raises(TargetingError) as excinfo:47 Target.the(test_name).located_by("*").found_by(Tester)48 assert test_name in str(excinfo.value)49def test_all_found_by(Tester):50 test_locator = (By.ID, "baked beans")51 Target.the("test").located(test_locator).all_found_by(Tester)52 mocked_browser = Tester.ability_to(BrowseTheWeb).browser53 mocked_browser.find_elements.assert_called_once_with(*test_locator)54def test_all_found_by_raises(Tester):55 test_name = "transmogrifier"56 mocked_browser = Tester.ability_to(BrowseTheWeb).browser57 mocked_browser.find_elements.side_effect = WebDriverException58 with pytest.raises(TargetingError) as excinfo:59 Target.the(test_name).located_by("*").all_found_by(Tester)...

Full Screen

Full Screen

project_settings.py

Source:project_settings.py Github

copy

Full Screen

1import sys2platform=sys.platform3browsers=["chrome desktop mac","safari desktop mac","firefox desktop mac","chrome desktop win","firefox desktop win","ie desktop win","edge desktop win",4"chrome phone android 7","chrome phone android 8","chrome phone android 9","safari phone ios 12",5"safari phone ios 11","safari phone ios 10","safari tablet ios","chrome tablet android"]6class ProjectSettings(object):7 def __init__(self,test_name):8 self.test_name=test_name 9 10 @property11 def project_folders(self):12 if platform=="win32":self.tests_methods="\\tests_methods";self.tests_screenshots="\\tests_screenshots";\13 self.tests_webdrivers="\\tests_webdrivers\\win";self.test_screenshots=self.tests_screenshots+"\\"+self.test_name;\14 self.tests_locators="\\tests_locators" 15 elif platform=="darwin":self.tests_methods="/tests_methods";self.tests_screenshots="/tests_screenshots";\16 self.tests_webdrivers="/tests_webdrivers/mac";self.test_screenshots=self.tests_screenshots+"/"+self.test_name;\17 self.tests_locators="/tests_locators" 18 return self.tests_methods,self.tests_webdrivers,self.tests_screenshots,\19 self.test_screenshots,self.tests_locators 20 @property21 def test_parameters(self):22 if self.test_name=="TC_proba":self.test_part="full test";self.test_locator="TCproba_locators"23 if self.test_name=="TC_Beh_Integration_Form_CMandatory":self.test_part="full test";self.test_locator="bh_cmandatory_locators" 24 if self.test_name=="TC_scroll_test":self.test_part="full test";self.test_locator="scroll_test_locators" 25 if self.test_name=="TC_Call_JavaScript_player":self.test_part="full test";self.test_locator="TCCallJavaScript_locators" 26 return self.test_part,self.test_locator27def running_test():28 name=""29 browser=""30 test_type="LOCAL"31 #self.test_type="CBT"...

Full Screen

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