Best Python code snippet using fMBT_python
test_timeline.py
Source:test_timeline.py
...145 timeline = self.get_timeline()146 tpos = timeline.position147 end = self.search_clip_end(30, seektime, timeline)148 dogtail.rawinput.absoluteMotion(tpos[0] + end / 2 - 2, tpos[1] + 30)149 registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Control_L"), None, KEY_PRESS)150 dogtail.rawinput.press(tpos[0] + end / 2 - 2, tpos[1] + 30)151 sleep(0.5)152 dogtail.rawinput.absoluteMotion(tpos[0] + end / 2 - 100, tpos[1] + 30)153 sleep(0.5)154 dogtail.rawinput.release(tpos[0] + end / 2 - 100, tpos[1] + 30)155 registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Control_L"), None, KEY_RELEASE)156 self.nextb.click()157 self.assertNotEqual(seektime.text, "0:00:02.455", "Not ripled, but trimed")158 #Regresion test of adding effect159 #Add effect160 tab = self.pitivi.tab("Effect Library")161 tab.click()162 conftab = self.pitivi.tab("Clip configuration")163 conftab.click()164 center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)165 table = conftab.child(roleName="table")166 icon = self.search_by_text("Agingtv ", tab, roleName="icon")167 self.improved_drag(center(icon), center(table))168 self.nextb.click()169 seekbefore = seektime.text170 #Try riple and roll171 dogtail.rawinput.absoluteMotion(tpos[0] + end / 2 - 102, tpos[1] + 30)172 registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Control_L"), None, KEY_PRESS)173 dogtail.rawinput.press(tpos[0] + end / 2 - 102, tpos[1] + 30)174 sleep(0.5)175 dogtail.rawinput.absoluteMotion(tpos[0] + end / 2 - 200, tpos[1] + 30)176 sleep(0.5)177 dogtail.rawinput.release(tpos[0] + end / 2 - 200, tpos[1] + 30)178 registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Control_L"), None, KEY_RELEASE)179 self.nextb.click()180 self.assertNotEqual(seektime.text, seekbefore, "Not ripled affter adding effect")181 def test_image_video_mix(self):182 files = ["1sec_simpsons_trailer.mp4", "flat_colour2_640x480.png",183 "flat_colour4_1600x1200.jpg", "flat_colour1_640x480.png",184 "flat_colour3_320x180.png", "flat_colour5_1600x1200.jpg"]185 samples = self.import_media_multiple(files)186 seektime = self.search_by_text("0:00:00.000", self.pitivi, roleName="text")187 timeline = self.get_timeline()188 tpos = timeline.position189 #One video, one image190 for sample in samples[1:]:191 self.insert_clip(sample)192 self.insert_clip(samples[0])193 end = self.search_clip_end(30, seektime, timeline)194 cend = end / 11.139195 dogtail.rawinput.absoluteMotion(tpos[0] + cend - 2, tpos[1] + 30)196 registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Shift_L"), None, KEY_PRESS)197 dogtail.rawinput.press(tpos[0] + cend - 2, tpos[1] + 30)198 sleep(0.5)199 dogtail.rawinput.absoluteMotion(tpos[0] + cend - 40, tpos[1] + 30)200 sleep(0.5)201 dogtail.rawinput.release(tpos[0] + cend - 40, tpos[1] + 30)202 registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Shift_L"), None, KEY_RELEASE)203 self.nextb.click()204 self.assertNotEqual(seektime.text, "0:00:11.139")...
rawinput.py
Source:rawinput.py
...183 keySym = getattr(Gdk, 'KEY_' + keyName)184 except AttributeError:185 raise KeyError(keyName)186 return keySym187def keyNameToKeyCode(keyName):188 """189 Use GDK to get the keycode for a given keystring.190 Note that the keycode returned by this function is often incorrect when191 the requested keystring is obtained by holding down the Shift key.192 Generally you should use uniCharToKeySym() and should only need this193 function for nonprintable keys anyway.194 """195 keymap = Gdk.Keymap.get_for_display(Gdk.Display.get_default())196 entries = keymap.get_entries_for_keyval(197 Gdk.keyval_from_name(keyName))198 try:199 return entries[1][0].keycode200 except TypeError:201 pass202def pressKey(keyName):203 """204 Presses (and releases) the key specified by keyName.205 keyName is the English name of the key as seen on the keyboard. Ex: 'enter'206 Names are looked up in Gdk.KEY_ If they are not found there, they are207 looked up by uniCharToKeySym().208 """209 keySym = keyNameToKeySym(keyName)210 registry.generateKeyboardEvent(keySym, None, KEY_SYM)211 doTypingDelay()212def keyCombo(comboString):213 """214 Generates the appropriate keyboard events to simulate a user pressing the215 specified key combination.216 comboString is the representation of the key combo to be generated.217 e.g. '<Control><Alt>p' or '<Control><Shift>PageUp' or '<Control>q'218 """219 strings = []220 for s in comboString.split('<'):221 if s:222 for S in s.split('>'):223 if S:224 S = keyNameAliases.get(S.lower(), S)225 strings.append(S)226 for s in strings:227 if not hasattr(Gdk, s):228 if not hasattr(Gdk, 'KEY_' + s):229 raise ValueError("Cannot find key %s" % s)230 modifiers = strings[:-1]231 finalKey = strings[-1]232 for modifier in modifiers:233 code = keyNameToKeyCode(modifier)234 registry.generateKeyboardEvent(code, None, KEY_PRESS)235 code = keyNameToKeyCode(finalKey)236 registry.generateKeyboardEvent(code, None, KEY_PRESSRELEASE)237 for modifier in modifiers:238 code = keyNameToKeyCode(modifier)239 registry.generateKeyboardEvent(code, None, KEY_RELEASE)240 doDelay()241def holdKey(keyName):242 code = keyNameToKeyCode(keyName)243 registry.generateKeyboardEvent(code, None, KEY_PRESS)244 doDelay()245def releaseKey(keyName):246 code = keyNameToKeyCode(keyName)247 registry.generateKeyboardEvent(code, None, KEY_RELEASE)...
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!!