Exemplo n.º 1
0
def get_rpa(timeout=10):
    r.init()
    r.url('https://www.google.com')
    r.type('//*[@name="q"]', 'decentralization[enter]')
    print(r.read('result-stats'))
    r.snap('page', 'results.png')
    r.close()
def process(country, numOfAdults, numOfInfants, numOfChildren, fromDate, toDate):
    start = time.time()

    airbnb.initialize()
    r.wait()
	#airbnb.select_stay()
	#r.wait()
    airbnb.close_cookie_popup()
    airbnb.enter_country_city(country)
    airbnb.enter_dates(fromDate,toDate)
	#airbnb.enter_personnel(2,2,1)
    airbnb.enter_personnel(numOfAdults,numOfInfants,numOfChildren)
    airbnb.click_search()
    r.wait()
	#airbnb.recreate_temp()
    airbnb.snap_map()
    data = airbnb.extract_stay_info_as_data()
    print("Sending Date back to controller")
    print(data)
    r.close()

    end = time.time()

    elapsed = end - start
    print(f'Time Elapsed: {elapsed} seconds')
	
    response =  data
    
    return response
Exemplo n.º 3
0
def today_dollar():
    r.init()
    r.url('https://www.melhorcambio.com/dolar-hoje')
    sleep(4)
    dolar = r.read('//*[@id="comercial"]')
    sleep(2)
    print(f'{dolar} | {datetime.today()}')
    r.close()
    return dolar
Exemplo n.º 4
0
def convert_to_greyscale(**context):
	filename = 'results.png'
	img = cv2.imread(filename)
	imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)# convert to gray
	context['ti'].xcom_push(key='imgray',value=imgray)
	context['ti'].xcom_push(key='filename',value=filename)
	filename_gray = filename + '_box.jpg'
	context['ti'].xcom_push(key='filename_gray',value=filename_gray)
	# save img
	cv2.imwrite(filename_gray, imgray)
	r.close()
Exemplo n.º 5
0
def dollar_cannadian():
    r.init()
    r.url('https://www.melhorcambio.com/dolar-hoje')
    sleep(4)
    r.click('//*[@id="dock"]/ul/li[2]/a')
    sleep(4)
    dolar_c = r.read('//*[@id="comercial"]')
    sleep(2)
    print(f'{dolar_c} | {datetime.today()}')
    r.close()
    return dolar_c
Exemplo n.º 6
0
def do_web_auto(search_data):
    r.init()
    r.url('https://www.google.com')
    r.click('.gLFyf.gsfi')

    r.type('.gLFyf.gsfi', f'{search_data}[enter]')
    #r.type("//*[@name='q']', 'decentralization[enter]")
    #print(r.read('result-stats'))
    r.snap('page', 'results.png')
    res = r.read('result-stats')
    r.close()
    return res
def convert_html_to_jpg():
    URL = "http://127.0.0.1:5000/get_html"  #localhost

    r.init()
    r.url(URL)
    print('Zooming out')
    r.click('//*[@class="leaflet-control-zoom-out"]')
    r.click('//*[@class="leaflet-control-zoom-out"]')
    print('Waiting to load...')
    r.wait(18)

    print('Snapping')
    r.snap('//html/body', "./Images/map.jpg")
    print('Done.')

    r.close()
Exemplo n.º 8
0
def main():
    url = 'https://rpachallengeocr.azurewebsites.net/'
    accessible_url = connection_url_verify(url)

    site_init(url) if accessible_url else print("Bye.")

    max_window_img = img_path('max_window.png')
    move_to_center_img_click(str(max_window_img))

    p.sleep(1)
    p.hotkey('tab')
    p.press('right', presses=10)

    p.sleep(0.5)
    next_btn_img = img_path('next.png')
    extract_table_from_page(str(next_btn_img))

    r.close()
Exemplo n.º 9
0
def process(country, numOfAdults, numOfInfants, numOfChildren, fromDate, toDate):
    start = time.time()

    airbnb.initialize()
    r.wait()
    airbnb.select_stay()
    r.wait()
    airbnb.enter_country_city(country)
    airbnb.close_cookie_popup()
    r.wait()
    airbnb.enter_dates(fromDate,toDate)
    r.wait()
    #adult, infant, child
    #airbnb.enter_personnel(1,2,3)
    airbnb.enter_personnel(numOfAdults,numOfInfants,numOfChildren)

    #airbnb.recreate_temp()
    airbnb.snap_map()
    data = airbnb.extract_stay_info_as_data()
    print("Sending Date back to controller")
    print(data)
    r.close()

    end = time.time()

    elapsed = end - start
    print(f'Time Elapsed: {elapsed} seconds')  

    response =  """
            Country : {0}
            Num: {1}
            From: {2}
            To: {3}
        """.format(country, numOfPeople, fromDate, toDate)
    
    return response
Exemplo n.º 10
0
import rpa as r 
from time import sleep
import pyautogui as p

r.init()
sleep(2)
r.url('http://www.google.com')
window = p.getActiveWindow()
window.maximize()
sleep(2)
# r.type('//*[@id="tsf"]/div[2]/div[1]/div[1]/div/div[2]/input', 'Imune Kids[enter]')
r.type('//*[@name="q"]', 'Imune Kids[enter]')

sleep(2)
r.snap('page', 'img.png')
sleep(2)
r.close()
Exemplo n.º 11
0
rpa.init()
rpa.url('http://rpachallenge.com/')
window = ui.getActiveWindow()
window.maximize()

ui.sleep(5)

rpa.download('http://rpachallenge.com/assets/downloadFiles/challenge.xlsx',
             'challenge.xlsx')
ui.sleep(2)

df = pd.DataFrame(pd.read_excel(r'challenge.xlsx', sheet_name='Sheet1'))

rpa.click('/html/body/app-root/div[2]/app-rpa1/div/div[1]/div[6]/button')

for row in df.itertuples():
    rpa.type('//*[@ng-reflect-name="labelFirstName"]', row[1])
    rpa.type('//*[@ng-reflect-name="labelLastName"]', row[2])
    rpa.type('//*[@ng-reflect-name="labelCompanyName"]', row[3])
    rpa.type('//*[@ng-reflect-name="labelRole"]', row[4])
    rpa.type('//*[@ng-reflect-name="labelAddress"]', row[5])
    rpa.type('//*[@ng-reflect-name="labelEmail"]', row[6])
    rpa.type('//*[@ng-reflect-name="labelPhone"]', str(row[7]))
    rpa.click('/html/body/app-root/div[2]/app-rpa1/div/div[2]/form/input')
    ui.sleep(1)

ui.sleep(5)
ui.screenshot('score.png')
rpa.close()
Exemplo n.º 12
0
def end_challenge():
    r.snap('page', 'registry.png')
    r.wait(1)
    r.close()
Exemplo n.º 13
0
# this makes use of xpath (using chrome, inspect the element > right-click on highlighted element > 
# copy > copy xpath)
bot.init()
bot.url('http://www.rpachallenge.com')
# start the clock
bot.click('/html/body/app-root/div[2]/app-rpa1/div/div[1]/div[6]/button')
# loop through the records and input onto website
for r in range(2, sheet.max_row + 1):
    # first name
    bot.type('//*[@ng-reflect-name="labelFirstName"]', sheet.cell(row=r, column=1).value)
    # last name
    bot.type('//*[@ng-reflect-name="labelLastName"]', sheet.cell(row=r, column=2).value)
    # company name
    bot.type('//*[@ng-reflect-name="labelCompanyName"]', sheet.cell(row=r, column=3).value)
    # role in company
    bot.type('//*[@ng-reflect-name="labelRole"]', sheet.cell(row=r, column=4).value)
    # address
    bot.type('//*[@ng-reflect-name="labelAddress"]', sheet.cell(row=r, column=5).value)
    # email
    bot.type('//*[@ng-reflect-name="labelEmail"]', sheet.cell(row=r, column=6).value)
    # phone number
    bot.type('//*[@ng-reflect-name="labelPhone"]', str(sheet.cell(row=r, column=7).value))
    # click submit
    bot.click('/html/body/app-root/div[2]/app-rpa1/div/div[2]/form/input')
# get result
print('RPA Challenge result: ' + bot.read('/html/body/app-root/div[2]/app-rpa1/div/div[2]/div[2]'))
# take screenshot
bot.snap('page', 'rpa-challenge-result.png')
# close the browser
bot.close()
Exemplo n.º 14
0
  def sigaaRPA(self):
    r.init()
    r.timeout(30)

    while(self.state > 0):

      if self.terminateBot:
        r.close()
        break

      elif self.state == 1:
        # use url('your_url') to go to web page, url() returns current URL
        r.url('https://sigaa.upb.edu.co/ssomanager/c/SSB')
        self.state = self.state + 1

      elif self.state == 2:
        # use type() to use the keyboard to write something
        if r.exist(X.username) & r.present(X.username):
          r.type(X.username, '000290164')
          r.type(X.password, 'Tandres1997_')
          self.state = self.state + 1
        else:
          print("Couldn\'t find Username and Password Components")
          self.state = 1

      elif self.state == 3:
        # use click() to click on an UI element or x, y location
        self.state = click(X.login, self.state)

      elif self.state == 4:
        ## hace click en Estudiantes
        self.state = click(X.estudiantes, self.state)

      elif self.state == 5:
        ## Hace click en Seguimiento a la formación
        self.state = click(X.seguimieto, self.state)

      elif self.state == 6:
        ## hace click en Calificaciones parciales
        self.state = click(X.calif, self.state)

      elif self.state == 7:
        ## Selecciona el semestre del cual quiere mirar las notas
        r.select(X.semester, self.semester)
        self.state = self.state + 1

      elif self.state == 8:
        ## se hace click en enviar
        r.click(X.enviar)
        self.state = self.state + 1

      elif self.state == 9:
        tablexpath = ''
        r.wait(2)
        numCursos = r.count('//*[@class="datadisplaytable"][2]/tbody/tr/td/a')
        for i in range(2,numCursos+2):
          tablexpath = '//*[@class="datadisplaytable"][2]/tbody/tr['+ str(i) +']/td/a'
          if r.exist(tablexpath):
            r.click(tablexpath)
            r.wait(1)
            pagetitle = r.read('//div[@id="pagetitle"]')
            if pagetitle == 'Detalle de Calificación de Componente':
              materia = r.read('//*[@class="datadisplaytable"][1]/tbody/tr[5]/td[2]')
              print(materia)
              r.snap('page', './notas/s'+self.semester+'/'+ materia +'.png')
              # r.table('//table[@class="datadisplaytable"][2]', './csv/table'+str(i-1)+'.csv')
            r.dom('history.back()')

        # use wait() to wait for a number of seconds
        # default wait() is 5 seconds
        r.wait(5)
        self.terminateBot = True
      elif self.state == 10:
        r.dom('history.back()')
Exemplo n.º 15
0
def b2wRegister(cnpj, loginEmail, customerName, customerCpf, customerPhone,
                customerPosition, site, mei, registrationState):
    r.init()
    r.url('https://www.b2wmarketplace.com.br/v3/registre-se')
    p.sleep(15)

    p.sleep(3)

    # page1
    # cnpj
    r.type(
        '/html/body/app-root/div/app-signup/main/section[2]/div/div/div/form[1]/div/div[1]/div/input',
        str(cnpj))
    # loginEmail
    r.type(
        '/html/body/app-root/div/app-signup/main/section[2]/div/div/div/form[1]/div/div[2]/div/input',
        str(loginEmail))
    r.wait(5.0)

    p.screenshot('b2wCadastroPrimeiraParte.png')
    r.wait(3.0)

    # submit
    r.click(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[1]/div/div[4]/button'
    )
    r.click(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[1]/div/div[4]/button'
    )
    r.wait(5.0)
    # page2
    if mei == True:
        # click checkbox mei
        r.click(
            '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[2]/div/div/div/input'
        )
    else:
        #inscriçãoEstadual
        r.type(
            '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[2]/div/div/input',
            str(registrationState))
    # customerName
    r.type(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[3]/div/input',
        str(customerName))
    '''
        for tribo urbana, client role never will be:
        'Colaborador(a) da Empresa'
        only: owner or partner
        so, do not need a conditional for input 'Colaborador(a) da Empresa' role
    '''
    # customerPosition
    r.type(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[4]/div/select',
        str(customerPosition))
    # customerCpf
    r.type(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[6]/div/input',
        str(customerCpf))
    # customerPhone
    r.type(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[8]/div/input',
        str(customerPhone))
    # site
    r.type(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[7]/div/input',
        str(site))

    p.screenshot('b2wCadastroSegundaParte.png')

    # submit
    r.click(
        '//*[@id="main"]/app-signup/main/section[2]/div/div/div/form[2]/div/div[11]/button'
    )
    p.sleep(10)

    #read email, get code and confirm
    readEmailToHtml()
    p.sleep(12)
    p.hotkey('alt', 'tab')

    p.sleep(1)
    # clickEmailCodeInput()
    r.click('//*[@id="confirmEmail"]/div/div/div[2]/div/div/input')
    r.click('//*[@id="confirmEmail"]/div/div/div[2]/div/div/input')
    r.type('//*[@id="confirmEmail"]/div/div/div[2]/div/div/input',
           str(emailCodeB2w()))
    p.sleep(3)
    # p.write(codeEmailB2w())
    p.sleep(3)
    # clickEmailCodeConfirm()
    r.click('//*[@id="confirmEmail"]/div/div/div[3]/div[2]/button')
    r.click('//*[@id="confirmEmail"]/div/div/div[3]/div[2]/button')

    r.wait(10.0)
    p.screenshot('b2wTerceiraParte.png')
    r.wait(1.0)
    r.close()