How to use buttonsR method in pyatom

Best Python code snippet using pyatom_python

test.py

Source:test.py Github

copy

Full Screen

...100 orders = pd.concat([today_orders, history_orders])101 return orders102def _table_to_dataframe(header_key):103 global _tdx104 table = _tdx.windows()[0].buttonsR(header_key)[0].AXParent.AXParent105 rows = table._convenienceMatch('AXRow', 'AXRoleDescription', 'table row')106 data = [[column.AXValue for column in row.AXChildren] for row in rows]107 columns = [button.AXTitle for button in table.buttonsR()]108 import pandas as pd109 return pd.DataFrame(data, columns=columns)110def buy(codes, positions):111 # logger.debug('enter buy')112 global _tdx113 _activate()114 time.sleep(0.1)115 # logger.debug('will press buy button')116 _tdx.windows()[0]._convenienceMatch('AXCheckBox', 'AXTitle', '买入')[0].Press()117 time.sleep(0.2)118 codes = [codes] if isinstance(codes, str) else codes119 # logger.debug('loop codes for buy')120 for code, money in zip(codes, positions):121 # logger.debug('target code is: {}'.format(code))122 try:123 time.sleep(0.2)124 # logger.debug('will press order type 1')125 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()126 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()127 types = _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[1].AXChildren[128 0].AXChildren129 type_index = 0130 # logger.debug('will click type option')131 _click(types[type_index])132 time.sleep(0.1)133 # logger.debug('set code focus')134 _tdx.windows()[0].textFields()[0].AXFocused = True135 _tdx.windows()[0].textFields()[0].setString('AXValue', code)136 # _tdx.windows()[0].textFields()[0].Confirm()137 time.sleep(1.5)138 price = _tdx.windows()[0].textFields()[2].AXValue139 price = float(price)140 # logger.debug('price is: {}'.format(price))141 amount = int(money / price / 100) * 100142 if amount < 100:143 print(33)144 # logger.error('money: {} can not buy {} 100 shares, stock price: {}'.format(money, code, price))145 # amount = 100146 # logger.debug('amount is: {}'.format(amount))147 _tdx.windows()[0].textFields()[1].setString('AXValue', amount)148 _tdx.windows()[0].textFields()[1].Confirm()149 time.sleep(0.5)150 # logger.debug('select order type option')151 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()152 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()153 # time.sleep(0.1)154 types = _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[1].AXChildren[155 0].AXChildren156 type_index = 4 if len(types) > 3 else 1157 # logger.debug('click order option: {}'.format(types[type_index]))158 _click(types[type_index])159 time.sleep(0.1)160 if not DEBUG:161 _click(_tdx.windows()[0].buttonsR('买入下单')[0])162 time.sleep(0.2)163 _confirmIfMessage()164 time.sleep(0.5)165 _confirmIfMessage()166 time.sleep(0.2)167 except:168 pass169 # logger.exception('Exception while tdx.buy')170def sell(codes):171 # logger.debug('enter sell')172 global _tdx173 _activate()174 time.sleep(0.1)175 # logger.debug('press the sell button')176 _tdx.windows()[0]._convenienceMatch('AXCheckBox', 'AXTitle', '卖出')[0].Press()177 time.sleep(0.1)178 codes = [codes] if isinstance(codes, str) else codes179 # logger.debug('loop codes for sell')180 for code in codes:181 # logger.debug('target code: {}'.format(code))182 try:183 _tdx.windows()[0].textFields()[0].AXFocused = True184 _tdx.windows()[0].textFields()[0].setString('AXValue', code)185 # _tdx.windows()[0].textFields()[0].Confirm()186 time.sleep(1.5)187 _click(_tdx.windows()[0].buttonsR('全部')[0])188 time.sleep(0.1)189 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()190 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()191 # time.sleep(0.1)192 types = _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[1].AXChildren[193 0].AXChildren194 type_index = 4 if len(types) > 3 else 1195 # logger.debug('click order option: {}'.format(types[type_index]))196 _click(types[type_index])197 time.sleep(0.1)198 # stop_price = _tdx.windows()[0]._convenienceMatch('AXScrollArea', 'AXTitle', None)[1].AXChildren[0]._convenienceMatch('AXRow', 'AXTitle', None)[-3].AXChildren[1].AXValue199 if not DEBUG:200 _click(_tdx.windows()[0].buttonsR('卖出下单')[0])201 time.sleep(0.2)202 _confirmIfMessage()203 time.sleep(0.2)204 _confirmIfMessage()205 time.sleep(0.2)206 except:207 pass208 # logger.exception('Exception while tdx.sell')209# def query_order(codes, flag=None):210# global _tdx211# _activate()212# time.sleep(0.1)213# _tdx.windows()[0]._convenienceMatchR('AXCheckBox', 'AXTitle', '成交')[0].Press()214# time.sleep(0.2)215#216# codes = [codes] if isinstance(codes, str) else codes217def exit():218 global _tdx219 _activate()220 time.sleep(0.1)221 _tdx.sendKeyWithModifiers('q', [COMMAND_L])222 time.sleep(1)223def lockHide():224 global _tdx225 _activate()226 time.sleep(0.1)227 _tdx.windows()[0].buttonsR('锁定')[0].Press()228 time.sleep(0.1)229 _tdx.windows()[0].buttons()[-1].Press()230 time.sleep(0.1)231def _confirmIfMessage():232 try:233 title = _tdx.windows()[0].AXChildren[1].AXValue234 message = _tdx.windows()[0].AXChildren[2].AXValue235 if title in ('提示', '交易确认', '连接确认'):236 # logger.debug('confirm message {}: {}'.format(title, message))237 button = _tdx.windows()[0].AXChildren[3]238 if button.AXTitle in ('确定', '是'):239 button.Press()240 time.sleep(0.1)241 if 'KCBPCLI_CallProgramAndCommit' in message:242 minutes = 30243 # logger.info('KCBPCLI_CallProgramAndCommit失败, system in maitain, wait {} minutes ...'.format(minutes))244 time.sleep(60 * minutes)245 elif '接收应答超时或网络已断开' in message:246 minutes = 10247 # logger.info('接收应答超时或网络已断开, wait {} minutes...'.format(minutes))248 time.sleep(60 * minutes)249 except:250 pass251def _click(obj):252 position = obj.AXPosition253 size = list(obj.AXSize)254 size[0] = 60. if size[0] > 200 else size[0]255 coord = (position[0] + size[0] / 2, position[1] + size[1] / 2)256 obj.clickMouseButtonLeft(coord)257 time.sleep(0.1)258def _loginFirstIfUnlogin(account, password):259 global _tdx260 try:261 search_text = ''262 try:263 search_text = _tdx.windows()[0].AXChildren[1].AXChildren[1].AXTitle264 except:265 pass266 if len(search_text) > 0:267 if account is None or len(account) < 5 or password is None or len(password) < 6:268 raise Exception('You must assgin correct trade account and password for login!')269 else:270 return271 if _tdx.windows()[0].AXChildren[1].AXChildren[4].AXValue != 'c成都顺城大街(原人民中路)':272 _tdx.windows()[0].AXChildren[1].AXChildren[4].setString('AXValue', 'c成都顺城大街(原人民中路)')273 _tdx.windows()[0].AXChildren[1].AXChildren[4].AXChildren[0].Press()274 time.sleep(0.3)275 _click(_tdx.windows()[0].AXChildren[1].AXChildren[4].AXChildren[1].AXChildren[0].AXChildren[25])276 time.sleep(0.2)277 _tdx.windows()[0].AXChildren[1].AXChildren[6].setString('AXValue', account)278 _tdx.windows()[0].AXChildren[1].AXChildren[9].setString('AXValue', password)279 time.sleep(0.1)280 _tdx.windows()[0].AXChildren[1].AXChildren[13].Press()281 # logger.debug('will waiting for login button enabled')282 try:283 while not _tdx.windows()[0].AXChildren[1].AXChildren[13].AXEnabled:284 time.sleep(1)285 _confirmIfMessage()286 except:287 pass288 except:289 pass290 # logger.debug('exception at _loginFirstIfUnlogin', exc_info=True)291def _loginFirstIfLocked(password):292 global _tdx293 try:294 lock_text = []295 try:296 lock_text = _tdx.windows()[0].staticTextsR('交易界面已锁定*')297 except:298 pass299 if len(lock_text) > 0:300 if password is None or len(password) < 6:301 _loginFirstIfLocked.passwordFlag = True302 raise Exception('You must assgin correct trade password for login!')303 else:304 return305 text_password = _tdx.windows()[0].textFields()[0]306 if text_password.AXSubrole == 'AXSecureTextField':307 text_password.setString('AXValue', password)308 _tdx.windows()[0].buttonsR('确定')[0].Press()309 time.sleep(0.1)310 except Exception as ex:311 print(ex)312_loginFirstIfLocked.passwordFlag = False313def _activate():314 global _tdx315 while not _tdx.AXFrontmost:316 _confirmIfMessage()317 _tdx.activate()318 time.sleep(0.1)319 time.sleep(0.1)320 _confirmIfMessage()321 _confirmIfMessage()322def _sendKey(key):...

Full Screen

Full Screen

b1.py

Source:b1.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2#!/usr/bin/env python3# ejemplo entry.py4import pygtk5pygtk.require('2.0')6import gtk7import hack8###################### ventana ####################9class Main:10 def __init__(self):11 # create a new window12 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)13 self.window.set_border_width(5)14 self.window.set_size_request(500, 500)15 self.window.set_title("Benzetacil GTK v01")16 self.window.connect("delete_event", lambda w,e: gtk.main_quit())17 #Creo la tabla18 self.table = gtk.Table(10, 10, True)19 #Creo el lable URL20 self.label1 = gtk.Label("URL:")21 #Creo la caja de texto para la URL22 self.url = gtk.Entry()23 self.url.set_max_length(100)24 self.url.connect("activate", self.enter_callback, self.url)25 self.url.set_text("http://127.0.0.1/blindSQL/index.php?id_n=2")26 self.url.select_region(0, len(self.url.get_text()))27 #Creo la caja de texto para el output28 self.salida = gtk.TextView()29 self.salida.set_property('editable', False)30 self.buffer = self.salida.get_buffer()31 #Creo el boton conectar32 self.buttonRun = gtk.Button("Run")33 self.buttonRun.connect("clicked", self.conectar)34 #Creo el boton de sacar Tabla35 self.buttonST = gtk.Button("Tablas")36 self.buttonST.connect("clicked",self.conectarTablas)37 #Creo el boton de sacar Registros38 self.buttonSR = gtk.Button("Registros")39 self.buttonSR.connect("clicked",self.conectarRegistro)40 #creo un separador41 self.separator = gtk.HSeparator()42 #Creo un boton de exit43 self.buttonQuit = gtk.Button(stock=gtk.STOCK_CLOSE)44 self.buttonQuit.connect("clicked", lambda w: gtk.main_quit())45 #agrego el combo para econtrar errores46 self.combo = gtk.Combo()47 slist = ["Compara fuentes","Busca Patron"]48 self.combo.set_popdown_strings(slist)49 #agrego el combo para el methodo50 self.comboM = gtk.Combo()51 mlist = ["GET","POST"]52 self.comboM.set_popdown_strings(mlist)53 #creo un scroll window en un pack verticl54 scrolled_window = gtk.ScrolledWindow()55 scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)56 self.vbox=gtk.VBox(False,1)57 self.vbox.pack_start(scrolled_window, gtk.TRUE, gtk.TRUE, 0)58 scrolled_window.add_with_viewport(self.salida)59 #agrego los widgets60 self.window.add(self.table)61 self.table.attach(self.label1,0,1,0,1)62 self.table.attach(self.url,1,9,0,1)63 self.table.attach(self.buttonRun,9,10,0,1)64 self.table.attach(self.combo,0,3,1,2)65 self.table.attach(self.comboM,3,5,1,2)66 self.table.attach(self.buttonST,6,7,1,2)67 self.table.attach(self.buttonSR,7,8,1,2)68 self.table.attach(self.separator,0,10,2,3)69 self.table.attach(self.vbox,0,10,3,9)70 self.table.attach(self.buttonQuit,0,2,9,10)71 #muestrando72 self.window.show_all()73 def enter_callback(self, widget, url):74 entry_text = self.url.get_text()75 print "Entry contents: %s\n" % entry_text76 def conectarRegistro(self,widget):77 self.buffer.insert(self.buffer.get_end_iter(),"\n\n[------ [Registros!]------]\n")78 methodError = self.combo.entry.get_text()79 method = self.comboM.entry.get_text()80 #for db in range(0,len(self.bbddE)):81 obj3 = hack.atack(self.url.get_text(),self.bbddE,self.tablaE)82 def conectarTablas(self,widget):83 self.buffer.insert(self.buffer.get_end_iter(),"\n\n[------ [tablas!]------]\n")84 methodError = self.combo.entry.get_text()85 method = self.comboM.entry.get_text()86 #for db in range(0,len(self.bbddE)):87 obj2 = hack.atack(self.url.get_text(),self.bbddE,"")88 obj2.injBlind()89 tablaE = obj2.runBlind(methodError)90 for x in range(0,len(tablaE)):91 self.buffer.insert(self.buffer.get_end_iter(),"\n[+]"+tablaE[x])92 def conectar(self, widget):93 self.bbddE = ""94 #Se crea una instancia del modulo hack95 #la clase injection que es herencia de96 #la clase sitex.97 methodError = self.combo.entry.get_text()98 method = self.comboM.entry.get_text()99 obj = hack.atack(self.url.get_text(),"","")100 self.buffer.insert(self.buffer.get_end_iter(),obj.method(method))101 self.buffer.insert(self.buffer.get_end_iter(),obj.vulnerable())102 self.buffer.insert(self.buffer.get_end_iter(),"\n\n[------ [base de datos!]------]\n")103 obj.injBlindBBDD()104 self.bbddE = obj.runBlindBBDD(methodError)105 self.buffer.insert(self.buffer.get_end_iter(),"\n[+]"+self.bbddE)106if __name__ == "__main__":107 app = Main()...

Full Screen

Full Screen

funzioni.py

Source:funzioni.py Github

copy

Full Screen

1from http import cookies2from importlib.resources import contents3from bs4 import BeautifulSoup4import lxml5import requests6import os7import shutil8cartella = "C:\\Users\\franc\\Scripts\\anime\\file"9def search(name):10 if not os.path.exists(cartella):11 os.mkdir(cartella)12 13 params = (14 ('search', name),15 )16 cookies = {17 '__ddg1': 'xnXqWmNWqFb4XOuU0KJX',18 'cookieconsent_status': 'ok',19 'PHPSESSID': 'nefn0433nabr33le3nilt9pb84',20 'ASCookie': 'b798ab5eadfe343b990a4f2451d4748d',21 }22 headers = {23 'authority': 'www.animesaturn.it',24 'upgrade-insecure-requests': '1',25 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36',26 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',27 'sec-gpc': '1',28 'sec-fetch-site': 'same-origin',29 'sec-fetch-mode': 'navigate',30 'sec-fetch-dest': 'document',31 'referer': 'https://www.animesaturn.it/?d=1',32 'accept-language': 'en-US,en;q=0.9',33 }34 response = requests.get('https://www.animesaturn.it/animelist', params=params , headers=headers , cookies=cookies)35 with open(f'{cartella}/search.html', 'w', encoding="utf-8") as f:36 f.write(response.text)37 with open(f'{cartella}/search.html','r' ,encoding="utf-8") as f:38 content = f.read()39 soup = BeautifulSoup(content,'html.parser')40 linkall = soup.find_all("a",class_="thumb image-wrapper")41 link = []42 for l in linkall:43 link.append(l["href"])44 link = list(dict.fromkeys(link))45 #shutil.rmtree(cartella)46 return link47def choose(url):48 if not os.path.exists(cartella):49 os.mkdir(cartella)50 51 cookies = {52 '__ddg1': 'xnXqWmNWqFb4XOuU0KJX',53 'cookieconsent_status': 'ok',54 'PHPSESSID': 'nefn0433nabr33le3nilt9pb84',55 'ASCookie': 'b798ab5eadfe343b990a4f2451d4748d',56 }57 response = requests.get(url , cookies=cookies)58 59 with open(f'{cartella}/choose.html', 'w',encoding="utf-8") as f:60 f.write(response.text)61 62 with open(f'{cartella}/choose.html','r',encoding="utf-8") as f:63 content = f.read()64 65 soup = BeautifulSoup(content,'html.parser')66 67 buttonsR = soup.find_all("a", class_='btn btn-dark mb-1 bottone-ep')68 69 buttons = []70 for b in buttonsR:71 buttons.append(b["href"])72 #shutil.rmtree(cartella)73 return buttons74def episode(url):75 if not os.path.exists(cartella):76 os.mkdir(cartella)77 cookies = {78 '__ddg1': 'xnXqWmNWqFb4XOuU0KJX',79 'cookieconsent_status': 'ok',80 'PHPSESSID': 'nefn0433nabr33le3nilt9pb84',81 'ASCookie': 'b798ab5eadfe343b990a4f2451d4748d',82 }83 response = requests.get(url, cookies=cookies)84 with open(f"{cartella}/episode.html","w",encoding="utf-8") as f:85 f.write(response.text)86 with open(f"{cartella}/episode.html","r",encoding="utf-8") as f:87 content = f.read()88 soup = BeautifulSoup(content,"html.parser")89 div = soup.find("div",class_="card-body")90 episode = div.a['href']91 #shutil.rmtree(cartella)92 93 return episode94def play(url):95 if not os.path.exists(cartella):96 os.mkdir(cartella)97 cookies = {98 '__ddg1': 'xnXqWmNWqFb4XOuU0KJX',99 'cookieconsent_status': 'ok',100 'PHPSESSID': 'nefn0433nabr33le3nilt9pb84',101 'ASCookie': 'b798ab5eadfe343b990a4f2451d4748d',102 }103 response = requests.get(url, cookies=cookies)104 with open(f"{cartella}/ep.html","w" ,encoding="utf-8") as f:105 f.write(response.text)106 with open(f"{cartella}/ep.html","r",encoding="utf-8") as f:107 content = f.read()108 soup = BeautifulSoup(content, 'html.parser')109 video = soup.find_all('video')110 #print(video)111 if len(video) > 0:112 source = video[0].find_all('source')113 s = str(source)114 link = s.split('"')115 link = link[1]116 _ = os.system(f'vlc --fullscreen {link}')117 else:118 div = soup.find("div",class_="embed-responsive-item")119 #print(div)120 s = div.find_all("script")121 s = str(s[1])122 s = s.split('"')123 link = s[5]124 _ = os.system(f'vlc --fullscreen {link}')125 126 #shutil.rmtree(cartella)...

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