Best Python code snippet using pyatom_python
tests_date.js
Source:tests_date.js
1module("Date.Extensions");2test("inputmask(\"dd/mm/yyyy\") - input 2331973", function () {3 var $fixture = $("#qunit-fixture");4 $fixture.append('<input type="text" id="testmask" />');5 $("#testmask").inputmask("dd/mm/yyyy");6 $("#testmask")[0].focus();7 $("#testmask").SendKey("2");8 $("#testmask").SendKey("3");9 $("#testmask").SendKey("3");10 $("#testmask").SendKey("1");11 $("#testmask").SendKey("9");12 $("#testmask").SendKey("7");13 $("#testmask").SendKey("3");14 equal($("#testmask").val(), "23/03/1973", "Result " + $("#testmask").val());15 $("#testmask").remove();16});17test("inputmask(\"mm/dd/yyyy\") - input 3231973", function () {18 var $fixture = $("#qunit-fixture");19 $fixture.append('<input type="text" id="testmask" />');20 $("#testmask").inputmask("mm/dd/yyyy");21 $("#testmask")[0].focus();22 $("#testmask").SendKey("3");23 $("#testmask").SendKey("2");24 $("#testmask").SendKey("3");25 $("#testmask").SendKey("1");26 $("#testmask").SendKey("9");27 $("#testmask").SendKey("7");28 $("#testmask").SendKey("3");29 equal($("#testmask").val(), "03/23/1973", "Result " + $("#testmask").val());30 $("#testmask").remove();31});32test("inputmask(\"dd/mm/yyyy\") - input 29022012", function () {33 var $fixture = $("#qunit-fixture");34 $fixture.append('<input type="text" id="testmask" />');35 $("#testmask").inputmask("dd/mm/yyyy");36 $("#testmask")[0].focus();37 $("#testmask").SendKey("2");38 $("#testmask").SendKey("9");39 $("#testmask").SendKey("0");40 $("#testmask").SendKey("2");41 $("#testmask").SendKey("2");42 $("#testmask").SendKey("0");43 $("#testmask").SendKey("1");44 $("#testmask").SendKey("2");45 equal($("#testmask").val(), "29/02/2012", "Result " + $("#testmask").val());46 $("#testmask").remove();47});48test("inputmask(\"dd/mm/yyyy\") - input 29022013", function () {49 var $fixture = $("#qunit-fixture");50 $fixture.append('<input type="text" id="testmask" />');51 $("#testmask").inputmask("dd/mm/yyyy");52 $("#testmask")[0].focus();53 $("#testmask").SendKey("2");54 $("#testmask").SendKey("9");55 $("#testmask").SendKey("0");56 $("#testmask").SendKey("2");57 $("#testmask").SendKey("2");58 $("#testmask").SendKey("0");59 $("#testmask").SendKey("1");60 $("#testmask").SendKey("3");61 equal($("#testmask").val(), "29/02/201y", "Result " + $("#testmask").val());62 $("#testmask").remove();63});64test("inputmask(\"mm/dd/yyyy\") - input 02292012", function () {65 var $fixture = $("#qunit-fixture");66 $fixture.append('<input type="text" id="testmask" />');67 $("#testmask").inputmask("mm/dd/yyyy");68 $("#testmask")[0].focus();69 $("#testmask").SendKey("0");70 $("#testmask").SendKey("2");71 $("#testmask").SendKey("2");72 $("#testmask").SendKey("9");73 $("#testmask").SendKey("2");74 $("#testmask").SendKey("0");75 $("#testmask").SendKey("1");76 $("#testmask").SendKey("2");77 equal($("#testmask").val(), "02/29/2012", "Result " + $("#testmask").val());78 $("#testmask").remove();79});80test("inputmask(\"mm/dd/yyyy\") - input 02292013", function () {81 var $fixture = $("#qunit-fixture");82 $fixture.append('<input type="text" id="testmask" />');83 $("#testmask").inputmask("mm/dd/yyyy");84 $("#testmask")[0].focus();85 $("#testmask").SendKey("0");86 $("#testmask").SendKey("2");87 $("#testmask").SendKey("2");88 $("#testmask").SendKey("9");89 $("#testmask").SendKey("2");90 $("#testmask").SendKey("0");91 $("#testmask").SendKey("1");92 $("#testmask").SendKey("3");93 equal($("#testmask").val(), "02/29/201y", "Result " + $("#testmask").val());94 $("#testmask").remove();95});96test("inputmask(\"dd/mm/yyyy\") - input CTRL RIGHT", function () {97 var $fixture = $("#qunit-fixture");98 $fixture.append('<input type="text" id="testmask" />');99 $("#testmask").inputmask("dd/mm/yyyy");100 $("#testmask")[0].focus();101 $("#testmask").SendKey($.inputmask.keyCode.RIGHT, $.inputmask.keyCode.CONTROL);102 ok($("#testmask").val() != "dd/mm/yyyy", "Result " + $("#testmask").val());103 $("#testmask").remove();104});105test("inputmask(\"dd/mm/yyyy\") - input 2331973 BACKSPACE x4 2013", function () {106 var $fixture = $("#qunit-fixture");107 $fixture.append('<input type="text" id="testmask" />');108 $("#testmask").inputmask("dd/mm/yyyy");109 $("#testmask")[0].focus();110 $("#testmask").SendKey("2");111 $("#testmask").SendKey("3");112 $("#testmask").SendKey("3");113 $("#testmask").SendKey("1");114 $("#testmask").SendKey("9");115 $("#testmask").SendKey("7");116 $("#testmask").SendKey("3");117 $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);118 $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);119 $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);120 $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);121 $("#testmask").SendKey("2");122 $("#testmask").SendKey("0");123 $("#testmask").SendKey("1");124 $("#testmask").SendKey("3");125 equal($("#testmask").val(), "23/03/2013", "Result " + $("#testmask").val());126 $("#testmask").remove();127});128test("inputmask(\"dd/mm/yyyy\") - input 23373 ", function () {129 var $fixture = $("#qunit-fixture");130 $fixture.append('<input type="text" id="testmask" />');131 $("#testmask").inputmask("dd/mm/yyyy");132 $("#testmask")[0].focus();133 $("#testmask").Type("23373");134 equal($("#testmask").val(), "23/03/2073", "Result " + $("#testmask").val());135 $("#testmask").remove();136});137test("inputmask(\"dd/mm/yyyy\") - input 23318 - jimithing277", function () {138 var $fixture = $("#qunit-fixture");139 $fixture.append('<input type="text" id="testmask" />');140 $("#testmask").inputmask("dd/mm/yyyy");141 $("#testmask")[0].focus();142 $("#testmask").Type("23318");143 equal($("#testmask").val(), "23/03/2018", "Result " + $("#testmask").val());144 $("#testmask").remove();145});146test("inputmask(\"dd/mm/yyyy\", { yearrange: { minyear: 1900, maxyear: 2000 } }) - input 23373 ", function () {147 var $fixture = $("#qunit-fixture");148 $fixture.append('<input type="text" id="testmask" />');149 $("#testmask").inputmask("dd/mm/yyyy", { yearrange: { minyear: 1900, maxyear: 2000 } });150 $("#testmask")[0].focus();151 $("#testmask").Type("23373");152 equal($("#testmask").val(), "23/03/1973", "Result " + $("#testmask").val());153 $("#testmask").remove();154});155test("inputmask(\"hh:mm\") - add remove add", function () {156 var $fixture = $("#qunit-fixture");157 $fixture.append('<input type="text" id="testmask" />');158 $('#testmask').inputmask('hh:mm', { clearIncomplete: true });159 $('#testmask').inputmask('remove');160 $('#testmask').inputmask('hh:mm', { clearIncomplete: true });161 $("#testmask")[0].focus();162 $("#testmask").Type("abcdef");163 $("#testmask").Type("23:50");164 equal($("#testmask").val(), "23:50", "Result " + $("#testmask").val());165 $("#testmask").remove();166});167test("inputmask(\"mm/yyyy\") - input 31973", function () {168 var $fixture = $("#qunit-fixture");169 $fixture.append('<input type="text" id="testmask" />');170 $("#testmask").inputmask("mm/yyyy");171 $("#testmask")[0].focus();172 $("#testmask").Type("31973");173 equal($("#testmask").val(), "03/1973", "Result " + $("#testmask").val());174 $("#testmask").remove();175});176test("inputmask(\"mm/dd/yyyy\") - select some input 1 - Guamaso", function () {177 var $fixture = $("#qunit-fixture");178 $fixture.append('<input type="text" id="testmask" />');179 $("#testmask").inputmask("mm/dd/yyyy");180 $("#testmask")[0].focus();181 $.caret($("#testmask")[0], 0, 5);182 $("#testmask").Type("1");183 equal($("#testmask").val(), "1m/dd/yyyy", "Result " + $("#testmask").val());184 $("#testmask").remove();185});186test("inputmask(\"dd/mm/yyyy\") - input 2331973 - remove 23", function () {187 var $fixture = $("#qunit-fixture");188 $fixture.append('<input type="text" id="testmask" />');189 $("#testmask").inputmask("dd/mm/yyyy");190 $("#testmask")[0].focus();191 $("#testmask").Type("23031973");192 $.caret($("#testmask"), 0, 2);193 $("#testmask").SendKey($.inputmask.keyCode.DELETE);194 equal($("#testmask").val(), "dd/03/1973", "Result " + $("#testmask").val());195 $("#testmask").remove();196});197test("inputmask(\"dd/mm/yyyy\") - input 01011000 - Skiv22", function () {198 var $fixture = $("#qunit-fixture");199 $fixture.append('<input type="text" id="testmask" />');200 $("#testmask").inputmask("dd/mm/yyyy", { yearrange: { minyear: 1000, maxyear: 2099 } });201 $("#testmask")[0].focus();202 $("#testmask").Type("01011000");203 equal($("#testmask").val(), "01/01/1000", "Result " + $("#testmask").val());204 $("#testmask").remove();...
viera.py
Source:viera.py
1import urllib22class Viera(object):3 def __init__(self, hostname, control_url, service_type):4 self.hostname = hostname5 self.control_url = control_url6 self.service_type = service_type7 self.sendkey_action = Action('X_SendKey', ('X_KeyEvent',))8 def _sendkey(self, slug):9 req = self.sendkey_action.to_soap_request(10 self.control_url,11 self.hostname,12 self.service_type,13 (slug,),14 )15 urllib2.urlopen(req).read()16 def __unicode__(self):17 return u'<Hostname:%s ControlURL:%s ServiceType:%s>' % (18 self.hostname,19 self.control_url,20 self.service_type,21 )22 def vol_up(self):23 self._sendkey('NRC_VOLUP-ONOFF')24 def vol_down(self):25 self._sendkey('NRC_VOLDOWN-ONOFF')26 def mute(self):27 self._sendkey('NRC_MUTE-ONOFF')28 def num(self, number):29 for digit in str(number):30 self._sendkey('NRC_D%s-ONOFF' % digit)31 def power(self):32 self._sendkey('NRC_TV-ONOFF')33 def toggle_3D(self):34 self._sendkey('NRC_3D-ONOFF')35 def toggle_SDCard(self):36 self._sendkey('NRC_SD_CARD-ONOFF')37 def red(self):38 self._sendkey('NRC_RED-ONOFF')39 def green(self):40 self._sendkey('NRC_GREEN-ONOFF')41 def yellow(self):42 self._sendkey('NRC_YELLOW-ONOFF')43 def blue(self):44 self._sendkey('NRC_BLUE-ONOFF')45 def vtools(self):46 self._sendkey('NRC_VTOOLS-ONOFF')47 def cancel(self):48 self._sendkey('NRC_CANCEL-ONOFF')49 def option(self):50 self._sendkey('NRC_SUBMENU-ONOFF')51 def Return(self):52 self.sendkey('NRC_RETURN-ONOFF')53 def enter(self):54 self._sendkey('NRC_ENTER-ONOFF')55 def right(self):56 self._sendkey('NRC_RIGHT-ONOFF')57 def left(self):58 self._sendkey('NRC_LEFT-ONOFF')59 def up(self):60 self._sendkey('NRC_UP-ONOFF')61 def down(self):62 self._sendkey('NRC_DOWN-ONOFF')63 def display(self):64 self._sendkey('NRC_DISP_MODE-ONOFF')65 def menu(self):66 self._sendkey('NRC_MENU-ONOFF')67 def connect(self):68 self._sendkey('NRC_INTERNET-ONOFF')69 def link(self):70 self._sendkey('NRC_VIERA_LINK-ONOFF')71 def guide(self):72 self._sendkey('NRC_EPG-ONOFF')73 def text(self):74 self._sendkey('NRC_TEXT-ONOFF')75 def subtitles(self):76 self._sendkey('NRC_STTL-ONOFF')77 def info(self):78 self._sendkey('NRC_INFO-ONOFF')79 def index(self):80 self._sendkey('NRC_INDEX-ONOFF')81 def hold(self):82 self._sendkey('NRC_HOLD-ONOFF')83class Action(object):84 def __init__(self, name, arguments):85 self.name = name86 self.arguments = arguments87 def to_soap_request(self, url, hostname, service_type, values):88 assert len(values) == len(self.arguments)89 params = ''.join(['<%s>%s</%s>' % (arg, value, arg) for arg, value in zip(self.arguments, values)])90 soap_body = (91 '<?xml version="1.0"?>'92 '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'93 '<SOAP-ENV:Body>'94 '<m:%(method_name)s xmlns:m="%(service_type)s">'95 '%(params)s'96 '</m:%(method_name)s>'97 '</SOAP-ENV:Body>'98 '</SOAP-ENV:Envelope>'99 ) % {100 'method_name': self.name,101 'service_type': service_type,102 'params': params,103 }104 headers = {105 'Host': hostname,106 'Content-Length': len(soap_body),107 'Content-Type': 'text/xml',108 'SOAPAction': '"%s#%s"' % (service_type, self.name),109 }110 req = urllib2.Request(url, soap_body, headers)...
modif.py
Source:modif.py
2from time import sleep3import pyexcel, pyexcel_ods, os, ctypes4from SendKeys import SendKeys5from subprocess import call, Popen, PIPE6def sendKey(arg):7 global debug8 if debug: SendKeys(str(arg), turn_off_numlock=False,pause=0.3)9 else: SendKeys(str(arg), turn_off_numlock=False,pause=0.03)10def setCB(text):11 text = str(text)12 GMEM_DDESHARE = 0x200013 ctypes.windll.user32.OpenClipboard(0)14 ctypes.windll.user32.EmptyClipboard()15 hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text))+1)16 pchData = ctypes.windll.kernel32.GlobalLock(hCd)17 ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text))18 ctypes.windll.kernel32.GlobalUnlock(hCd)19 ctypes.windll.user32.SetClipboardData(1, hCd)20 ctypes.windll.user32.CloseClipboard()21 sleep(0.01)22def insert(ref, moq, desig, minif, info, tarif, purchase, special):23 print "Upravujem: ",ref, moq, desig, minif, info, tarif, purchase, special24 sendKey("%rm")25 try: setCB(ref.replace(".0",""))26 except: setCB(ref)27 sendKey("^v") 28 sendKey("~"*3)29 if moq:30 setCB("%d"%int(moq))31 sendKey("^v")32 sendKey("~")33 if desig:34 setCB(desig)35 sendKey("^v") 36 sendKey("{TAB}")37 if minif:38 setCB("%d"%int(minif))39 sendKey("^v")40 41 sendKey("{TAB}"*2)42 if info:43 setCB(info)44 sendKey("^v") 45 sendKey("~"*3) 46 if tarif:47 setCB("%.2f"%tarif)48 sendKey("^v")49 sendKey("~"*2)50 51 if purchase:52 setCB("%.2f"%purchase)53 sendKey("^v")54 55 sendKey("~")56 sendKey("+{TAB}")57 58 if special:59 setCB("%.2f"%special)60 sendKey("^v") 61 62 sendKey("{TAB}")63 sendKey("~"*5) 64 sendKey("%a")65if __name__ == "__main__":66 debug=input("Debug mode (0-no, 1-yes) - ")67 os.system("C:\gesco5\\taroffre.exe")68 69 sheet=pyexcel.load("items.ods")70 data = sheet.row[1:]71 for riadok in data:72 if riadok[0]!= "": insert(riadok[0],riadok[1],riadok[2],riadok[3],riadok[4],riadok[5], riadok[6], riadok[7])...
create.py
Source:create.py
...4from SendKeys import SendKeys5import platform, os, ctypes, webbrowser, tempfile6from subprocess import call, Popen, PIPE7debug=input("Debug mode (0-no, 1-yes) - ")8def sendKey(arg):9 global debug10 if debug: SendKeys(str(arg), turn_off_numlock=False,pause=0.2)11 else: SendKeys(str(arg), turn_off_numlock=False,pause=0.02)12def setCB(text):13 text = str(text)14 GMEM_DDESHARE = 0x200015 ctypes.windll.user32.OpenClipboard(0)16 ctypes.windll.user32.EmptyClipboard()17 hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text))+1)18 pchData = ctypes.windll.kernel32.GlobalLock(hCd)19 ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text))20 ctypes.windll.kernel32.GlobalUnlock(hCd)21 ctypes.windll.user32.SetClipboardData(1, hCd)22 ctypes.windll.user32.CloseClipboard()23 sleep(0.01)24def insert(marque, ref, moq, desig, minif, info, tarif, purchase):25 print marque, ref, moq, desig, minif, info, tarif, purchase26 sendKey("%rc")27 setCB(marque)28 sendKey("^v") 29 sendKey("{TAB}")30 sendKey("{ESC}")31 setCB(ref.replace(".0",""))32 sendKey("^v") 33 sendKey("{TAB}")34 sendKey("%d"%int(moq))35 sendKey("{TAB}") 36 setCB(desig)37 sendKey("^v") 38 sendKey("{TAB}")39 sendKey("%d"%int(minif))40 sendKey("{TAB}"*2)41 setCB(info)42 sendKey("^v")43 sendKey("{TAB}"*2) 44 sendKey("%s"%tarif)45 sendKey("{TAB}"*2)46 sendKey("%s"%purchase)47 sendKey("~"*7)48 sendKey("a")49if __name__ == "__main__":50 sleep(1)51 sheet=pyexcel.load("items.ods")52 data = sheet.row[1:]53 print "marque, ref, moq, desig, minif, info, tarif, purchase"54 for riadok in data:55 if riadok[0]!= "": insert(riadok[0],riadok[1],riadok[2],riadok[3],riadok[4],riadok[5],riadok[6], riadok[7])...
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!!