Advertisement
arvingarciaa

Feb 5

Feb 4th, 2020
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 39.93 KB | None | 0 0
  1. import time
  2. import unittest
  3. from selenium import webdriver
  4. from openpyxl import load_workbook
  5. from selenium.webdriver.common.by import By
  6. from selenium.webdriver.common.keys import Keys
  7. from selenium.webdriver.support import ui, expected_conditions
  8. from selenium.webdriver.support.wait import WebDriverWait
  9.  
  10. filepath = "/home/aj/Desktop/LORIELLE.xlsx"
  11. wb=load_workbook(filepath)
  12. sheet=wb.active
  13. rowCount = sheet.max_row
  14.  
  15. browser = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
  16. browser.get('https://ischo.searcaapps.org')
  17.  
  18. user = browser.find_element_by_id('username')
  19. user.send_keys('lavm')
  20. password = browser.find_element_by_id('password')
  21. password.send_keys('lavm@1234')
  22. password.send_keys(Keys.ENTER)
  23.  
  24. browser.get('https://ischo.searcaapps.org/ischo/scholarship/?d=all&p=40&fr=2019&to=2021')
  25. for k in range(40, 61):
  26.     rowNum = len(browser.find_elements_by_xpath('/html/body/section/article/table/tbody/tr'))
  27.     for i in range(1, rowNum):
  28.         currentStatus = browser.find_element_by_xpath("//tr[" + str(i) + "]//td[13]").text
  29.         if currentStatus == 'Alumni':
  30.             currentName = browser.find_element_by_xpath("//tr[" + str(i) + "]//td[2]").text
  31.             print("currentName = " + currentName)
  32.             browser.find_element_by_link_text(currentName).click()
  33.             browser.find_element_by_link_text('Edit').click()
  34.             for j in range(1, rowCount):
  35.                 if currentName == sheet.cell(row=j, column=6).value:
  36.                     currentRowExcel = j
  37.  
  38.             # DURATION START
  39.             if sheet.cell(row=currentRowExcel, column=28).value is None:
  40.                 browser.find_element_by_id('duration_from').send_keys(
  41.                     '06/01' + str(sheet.cell(row=currentRowExcel, column=27).value))
  42.             else:
  43.                 start_date = sheet.cell(row=currentRowExcel, column=28).value
  44.                 browser.find_element_by_id('duration_from').send_keys(
  45.                     str(start_date.strftime('%m')) + str(start_date.strftime('%d')) + str(start_date.year))
  46.  
  47.             # DURATION END
  48.             if sheet.cell(row=currentRowExcel, column=10).value is None:
  49.                 browser.find_element_by_id('duration_to').send_keys(
  50.                     '05/31' + str(sheet.cell(row=currentRowExcel, column=11).value))
  51.             else:
  52.                 end_date = sheet.cell(row=currentRowExcel, column=10).value
  53.                 browser.find_element_by_id('duration_to').send_keys(
  54.                     str(end_date.strftime('%m')) + str(end_date.strftime('%d')) + str(end_date.year))
  55.  
  56.             # DESIRED STUDY
  57.             checkboxes = browser.find_elements_by_name('university')
  58.             for checkbox in checkboxes:
  59.                 if checkbox.is_selected():  # If checkbox is ticked
  60.                     checkbox.click()  # to untick it
  61.  
  62.             if sheet.cell(row=currentRowExcel, column=16).value.lower() == 'uplb':
  63.                 browser.find_element_by_xpath("//input[@id='1']").click()
  64.             elif sheet.cell(row=currentRowExcel, column=16).value.lower() == 'ku':
  65.                 browser.find_element_by_xpath("//input[@id='2']").click()
  66.             elif sheet.cell(row=currentRowExcel, column=16).value.lower() == 'upm':
  67.                 browser.find_element_by_xpath("//input[@id='3']").click()
  68.             elif sheet.cell(row=currentRowExcel, column=16).value.lower() == 'ipb':
  69.                 browser.find_element_by_xpath("//input[@id='4']").click()
  70.             elif sheet.cell(row=currentRowExcel, column=16).value.lower() == 'ugm':
  71.                 browser.find_element_by_xpath("//input[@id='5']").click()
  72.             elif sheet.cell(row=currentRowExcel, column=16).value.lower() == 'ub':
  73.                 browser.find_element_by_xpath("//input[@id='6']").click()
  74.             else:
  75.                 browser.find_element_by_xpath(
  76.                     "/html[1]/body[1]/div[1]/form[1]/div[1]/div[5]/div[1]/div[7]/label[1]").click()
  77.                 browser.find_element_by_id('home_add').clear()
  78.                 browser.find_element_by_id('others').send_keys(sheet.cell(row=currentRowExcel, column=16).value)
  79.             # CLICK NEXT PAGE
  80.             browser.find_element_by_link_text('Next').click()
  81.             time.sleep(2.5)
  82.  
  83.             # LASTNAME
  84.             if sheet.cell(row=currentRowExcel, column=42).value is None:
  85.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[1]/input[1]").clear()
  86.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[1]/input[1]").send_keys(
  87.                     'N/A')
  88.             else:
  89.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[1]/input[1]").clear()
  90.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[1]/input[1]").send_keys(
  91.                     str(sheet.cell(row=currentRowExcel, column=42).value))
  92.             # FIRSTNAME
  93.             if sheet.cell(row=currentRowExcel, column=43).value is None:
  94.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[2]/input[1]").clear()
  95.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[2]/input[1]").send_keys(
  96.                     'N/A')
  97.             else:
  98.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[2]/input[1]").clear()
  99.                 browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/div[2]/div[1]/div[2]/input[1]").send_keys(
  100.                     str(sheet.cell(row=currentRowExcel, column=43).value))
  101.             # HOMEADDRESS
  102.             if sheet.cell(row=currentRowExcel, column=44).value is None:
  103.                 browser.find_element_by_id('home_add').clear()
  104.                 browser.find_element_by_id('home_add').send_keys('N/A')
  105.             else:
  106.                 browser.find_element_by_id('home_add').clear()
  107.                 browser.find_element_by_id('home_add').send_keys(str(sheet.cell(row=currentRowExcel, column=44).value))
  108.             # HOMETELEPHONE
  109.             if sheet.cell(row=currentRowExcel, column=45).value is None:
  110.                 browser.find_element_by_id('home_tel').clear()
  111.                 browser.find_element_by_id('home_tel').send_keys('N/A')
  112.             else:
  113.                 browser.find_element_by_id('home_tel').clear()
  114.                 browser.find_element_by_id('home_tel').send_keys(str(sheet.cell(row=currentRowExcel, column=45).value))
  115.             # HOMEFAX
  116.             if sheet.cell(row=currentRowExcel, column=47).value is None:
  117.                 browser.find_element_by_id('home_fax').clear()
  118.                 browser.find_element_by_id('home_fax').send_keys('N/A')
  119.             else:
  120.                 browser.find_element_by_id('home_fax').clear()
  121.                 browser.find_element_by_id('home_fax').send_keys(str(sheet.cell(row=currentRowExcel, column=47).value))
  122.             # E-MAIL
  123.             if sheet.cell(row=currentRowExcel, column=46).value is None:
  124.                 browser.find_element_by_id('home_email').clear()
  125.                 browser.find_element_by_id('home_email').send_keys('N/A')
  126.             else:
  127.                 browser.find_element_by_id('home_email').clear()
  128.                 browser.find_element_by_id('home_email').send_keys(str(sheet.cell(row=currentRowExcel, column=46).value))
  129.             # EMPLOYER
  130.             if sheet.cell(row=currentRowExcel, column=21).value is None:
  131.                 browser.find_element_by_id('employer').clear()
  132.                 browser.find_element_by_id('employer').send_keys('N/A')
  133.             else:
  134.                 browser.find_element_by_id('employer').clear()
  135.                 browser.find_element_by_id('employer').send_keys(str(sheet.cell(row=currentRowExcel, column=21).value))
  136.             # EMPLOYERADDRESS
  137.             if sheet.cell(row=currentRowExcel, column=22).value is None:
  138.                 browser.find_element_by_id('employer_add').clear()
  139.                 browser.find_element_by_id('employer_add').send_keys('N/A')
  140.             else:
  141.                 browser.find_element_by_id('employer_add').clear()
  142.                 browser.find_element_by_id('employer_add').send_keys(str(sheet.cell(row=currentRowExcel, column=22).value))
  143.             # POBOX
  144.             if sheet.cell(row=currentRowExcel, column=23).value is None:
  145.                 browser.find_element_by_id('employer_po').clear()
  146.                 browser.find_element_by_id('employer_po').send_keys('N/A')
  147.             else:
  148.                 browser.find_element_by_id('employer_po').clear()
  149.                 browser.find_element_by_id('employer_po').send_keys(str(sheet.cell(row=currentRowExcel, column=23).value))
  150.             # TELNUM
  151.             if sheet.cell(row=currentRowExcel, column=24).value is None:
  152.                 browser.find_element_by_id('employer_tel').clear()
  153.                 browser.find_element_by_id('employer_tel').send_keys('N/A')
  154.             else:
  155.                 browser.find_element_by_id('employer_tel').clear()
  156.                 browser.find_element_by_id('employer_tel').send_keys(str(sheet.cell(row=currentRowExcel, column=24).value))
  157.             # FAXNO
  158.             if sheet.cell(row=currentRowExcel, column=25).value is None:
  159.                 browser.find_element_by_id('employer_fax').clear()
  160.                 browser.find_element_by_id('employer_fax').send_keys('N/A')
  161.             else:
  162.                 browser.find_element_by_id('employer_fax').clear()
  163.                 browser.find_element_by_id('employer_fax').send_keys(str(sheet.cell(row=currentRowExcel, column=25).value))
  164.             # EMAIL
  165.             if sheet.cell(row=currentRowExcel, column=26).value is None:
  166.                 browser.find_element_by_id('employer_email').clear()
  167.                 browser.find_element_by_id('employer_email').send_keys('N/A')
  168.             else:
  169.                 browser.find_element_by_id('employer_email').clear()
  170.                 browser.find_element_by_id('employer_email').send_keys(
  171.                     str(sheet.cell(row=currentRowExcel, column=26).value))
  172.             # BIRTHDATE
  173.             birthDate = sheet.cell(row=currentRowExcel, column=40).value
  174.             if birthDate is not None:
  175.                 browser.find_element_by_xpath(
  176.                     "/html[1]/body[1]/div[1]/form[1]/div[2]/div[3]/div[2]/div[7]/div[1]/input[1]").click()
  177.                 browser.find_element_by_xpath(
  178.                     "/html[1]/body[1]/div[1]/form[1]/div[2]/div[3]/div[2]/div[7]/div[1]/input[1]").send_keys(
  179.                     str(birthDate.strftime('%m')) + str(birthDate.strftime('%d')) + str(birthDate.year))
  180.             else:
  181.                 print("birthDate empty")
  182.             # RADIOBUTTONS
  183.  
  184.             civilStatus = sheet.cell(row=currentRowExcel, column=41).value
  185.             if civilStatus is not None:
  186.                 if sheet.cell(row=currentRowExcel, column=41).value.lower() == 'single':
  187.                     browser.find_element_by_xpath("//div[11]//div[1]//label[1]").click()
  188.                 elif sheet.cell(row=currentRowExcel, column=41).value.lower() == 'married':
  189.                     browser.find_element_by_xpath("//div[11]//div[1]//label[2]").click()
  190.                 elif sheet.cell(row=currentRowExcel, column=41).value.lower() == 'widower':
  191.                     browser.find_element_by_xpath(
  192.                         "/html[1]/body[1]/div[1]/form[1]/div[2]/div[3]/div[2]/div[11]/div[1]/label[3]").click()
  193.             else:
  194.                 print("civilStatus is empty")
  195.             # PLACEOFBIRTH
  196.             browser.find_element_by_id('birth_place').clear()
  197.             browser.find_element_by_id('birth_place').send_keys('N/A')
  198.  
  199.             # CONTACTPERSON
  200.             browser.find_element_by_id('contact_name').clear()
  201.             browser.find_element_by_id('contact_name').send_keys('N/A')
  202.  
  203.             # PASSPORTNUMBER
  204.             browser.find_element_by_id('passport').clear()
  205.             browser.find_element_by_id('passport').send_keys('N/A')
  206.  
  207.             # PLACEOFISSUE
  208.             browser.find_element_by_id('passport_place').clear()
  209.             browser.find_element_by_id('passport_place').send_keys('N/A')
  210.  
  211.             # CLICK NEXT PAGE
  212.             browser.find_element_by_link_text('Next').click()
  213.             time.sleep(2.5)
  214.  
  215.             # NAMEOFCOLLEGE/UNIVERSITY
  216.             browser.find_element_by_xpath("//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").clear()
  217.             browser.find_element_by_xpath(
  218.                 "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").clear()
  219.             collegeName = sheet.cell(row=currentRowExcel, column=16).value
  220.             if collegeName is not None:
  221.                 if collegeName.lower() == 'uplb':
  222.                     browser.find_element_by_xpath(
  223.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  224.                         'University of the Philippines Los Baños (UPLB)')
  225.                     browser.find_element_by_xpath(
  226.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  227.                         'Philippines')
  228.                 elif collegeName.lower() == 'ku':
  229.                     browser.find_element_by_xpath(
  230.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  231.                         'Kasetsart University (KU)')
  232.                     browser.find_element_by_xpath(
  233.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  234.                         'Thailand')
  235.                 elif collegeName.lower() == 'upm':
  236.                     browser.find_element_by_xpath(
  237.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  238.                         'Universiti Putra Malaysia (UPM)')
  239.                     browser.find_element_by_xpath(
  240.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  241.                         'Malaysia')
  242.                 elif collegeName.lower() == 'ipb':
  243.                     browser.find_element_by_xpath(
  244.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  245.                         'Institut Pertanian Bogor (IPB)')
  246.                     browser.find_element_by_xpath(
  247.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  248.                         'Indonesia')
  249.                 elif collegeName.lower() == 'ugm':
  250.                     browser.find_element_by_xpath(
  251.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  252.                         'Universitas Gadjah Mada (UGM)')
  253.                     browser.find_element_by_xpath(
  254.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  255.                         'Indonesia')
  256.                 elif collegeName.lower() == 'ub':
  257.                     browser.find_element_by_xpath(
  258.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  259.                         'Universitas Brawijaya (UB)')
  260.                     browser.find_element_by_xpath(
  261.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  262.                         'Indonesia')
  263.                 elif collegeName.lower() == 'clsu':
  264.                     browser.find_element_by_xpath(
  265.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  266.                         'Central Luzon State University (CLSU)')
  267.                     browser.find_element_by_xpath(
  268.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  269.                         'Philippines')
  270.                 elif collegeName.lower() == 'tokyo-nodai':
  271.                     browser.find_element_by_xpath(
  272.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  273.                         'Tokyo-Nodai University')
  274.                     browser.find_element_by_xpath(
  275.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  276.                         'Japan')
  277.                 elif collegeName.lower() == 'rac':
  278.                     browser.find_element_by_xpath(
  279.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  280.                         'Royal Agricultural University')
  281.                     browser.find_element_by_xpath(
  282.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  283.                         'England')
  284.                 elif collegeName.lower() == 'asog':
  285.                     browser.find_element_by_xpath(
  286.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  287.                         'Ateneo de Manila University (ADMU)')
  288.                     browser.find_element_by_xpath(
  289.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  290.                         'Philippines')
  291.                 elif collegeName.lower() == 'upv':
  292.                     browser.find_element_by_xpath(
  293.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  294.                         'University of the Philippines Visayas (UPV)')
  295.                     browser.find_element_by_xpath(
  296.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  297.                         'Philippines')
  298.                 elif collegeName.lower() == 'unigott':
  299.                     browser.find_element_by_xpath(
  300.                         "//body/div/form/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/input[2]").send_keys(
  301.                         'University of Goettingen')
  302.                     browser.find_element_by_xpath(
  303.                         "//body/div[@class='container']/form[@class='form-horizontal']/div[@id='third_form']/div[@class='row']/div[@class='col-sm-4 col-md-4']/div[@class='appended-education-div']/div[2]/div[1]/input[1]").send_keys(
  304.                         'Germany')
  305.             else:
  306.                 pass
  307.             # DURATIONFROM
  308.             start_date = sheet.cell(row=currentRowExcel, column=28).value
  309.             browser.find_element_by_xpath("//div[@id='educfromdate']//input[@placeholder='yyyy']").clear()
  310.             browser.find_element_by_xpath("//div[@id='eductodate']//input[@placeholder='yyyy']").clear()
  311.             if start_date is None:
  312.                 browser.find_element_by_xpath("//div[@id='educfromdate']//input[@placeholder='yyyy']").send_keys(
  313.                     str(sheet.cell(row=currentRowExcel, column=27).value))
  314.             else:
  315.                 browser.find_element_by_xpath("//div[@id='educfromdate']//input[@placeholder='yyyy']").send_keys(
  316.                     str(start_date.year))
  317.             # DURATIONTO
  318.             end_date = sheet.cell(row=currentRowExcel, column=10).value
  319.             if end_date is None:
  320.                 browser.find_element_by_xpath("//div[@id='eductodate']//input[@placeholder='yyyy']").send_keys(
  321.                     str(sheet.cell(row=currentRowExcel, column=11).value))
  322.             else:
  323.                 browser.find_element_by_xpath("//div[@id='eductodate']//input[@placeholder='yyyy']").send_keys(
  324.                     str(end_date.year))
  325.             # MAJORSUBJECT
  326.             majorSubject = sheet.cell(row=currentRowExcel, column=18).value
  327.             browser.find_element_by_xpath("//body/div/form/div/div/div/div[1]/div[4]/div[1]/input[1]").clear()
  328.             browser.find_element_by_xpath("//body/div/form/div/div/div/div[1]/div[4]/div[1]/input[1]").send_keys(
  329.                 str(majorSubject))
  330.             # DIPLOMA/DEGREE
  331.             browser.find_element_by_xpath("//body/div/form/div/div/div/div[1]/div[5]/div[1]/input[1]").clear()
  332.             browser.find_element_by_xpath("//body/div/form/div/div/div/div[1]/div[5]/div[1]/input[1]").send_keys(
  333.                 str(majorSubject))
  334.  
  335.             # MASTERSDEGREE and #BACHELORSDEGREE
  336.             masters_university = sheet.cell(row=currentRowExcel, column=54).value
  337.             bachelors_university = sheet.cell(row=currentRowExcel, column=49).value
  338.             masters_country = sheet.cell(row=currentRowExcel, column=55).value
  339.             bachelors_country = sheet.cell(row=currentRowExcel, column=52).value
  340.             masters_from = sheet.cell(row=currentRowExcel, column=57).value
  341.             masters_to = sheet.cell(row=currentRowExcel, column=56).value
  342.             bachelors_from = sheet.cell(row=currentRowExcel, column=50).value
  343.             bachelors_to = sheet.cell(row=currentRowExcel, column=51).value
  344.             masters_major = sheet.cell(row=currentRowExcel, column=53).value
  345.             bachelors_major = sheet.cell(row=currentRowExcel, column=48).value
  346.  
  347.             if masters_university and bachelors_university is not None:
  348.                 browser.find_element_by_xpath("//a[@class='btn btn-default add-education']").click()
  349.                 browser.find_element_by_xpath("//a[@class='btn btn-default add-education']").click()
  350.                 # MASTERSUNIVERSITY and BACHELORSUNIVERSITY
  351.                 browser.find_element_by_xpath("//div//div//div//div//div[2]//div[1]//div[1]//div[1]//input[2]").clear()
  352.                 browser.find_element_by_xpath(
  353.                     "//div//div//div//div//div[2]//div[1]//div[1]//div[1]//input[2]").send_keys(str(masters_university))
  354.                 browser.find_element_by_xpath("//div//div//div//div//div//div[2]//div[1]//div[1]//input[2]").clear()
  355.                 browser.find_element_by_xpath("//div//div//div//div//div//div[2]//div[1]//div[1]//input[2]").send_keys(
  356.                     str(bachelors_university))
  357.                 # MASTERSCOUNTRY and BACHELORSCOUNTRY
  358.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[1]//div[2]//div[1]//input[1]").clear()
  359.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[1]//div[2]//div[1]//input[1]").send_keys(
  360.                     str(masters_country))
  361.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[2]//div[2]//div[1]//input[1]").clear()
  362.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[2]//div[2]//div[1]//input[1]").send_keys(
  363.                     str(bachelors_country))
  364.                 # MASTERSFROM and BACHELORSFROM
  365.                 browser.find_element_by_xpath(
  366.                     "//div[@id='collegediv']//div[1]//div[3]//div[1]//div[1]//input[1]").clear()
  367.                 browser.find_element_by_xpath(
  368.                     "//div[@id='collegediv']//div[1]//div[3]//div[1]//div[1]//input[1]").send_keys(str(masters_from))
  369.                 browser.find_element_by_xpath(
  370.                     "//div[@id='collegediv']//div[2]//div[3]//div[1]//div[1]//input[1]").clear()
  371.                 browser.find_element_by_xpath(
  372.                     "//div[@id='collegediv']//div[2]//div[3]//div[1]//div[1]//input[1]").send_keys(str(bachelors_from))
  373.                 # MASTERSTO and BACHELORSTO
  374.                 browser.find_element_by_xpath(
  375.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").clear()
  376.                 browser.find_element_by_xpath(
  377.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").send_keys(
  378.                     str(masters_to))
  379.  
  380.                 # MASTERSMAJOR and BACHELORSMAJOR
  381.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[4]//div[1]//input[1]").clear()
  382.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[5]//div[1]//input[1]").clear()
  383.                 browser.find_element_by_xpath("//div//div//div//div//div//div[2]//div[4]//div[1]//input[1]").clear()
  384.                 browser.find_element_by_xpath("//div//div//div//div//div//div[2]//div[5]//div[1]//input[1]").clear()
  385.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[4]//div[1]//input[1]").send_keys(
  386.                     str(masters_major))
  387.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[5]//div[1]//input[1]").send_keys(
  388.                     str(masters_major))
  389.                 browser.find_element_by_xpath("//div//div//div//div//div//div[2]//div[4]//div[1]//input[1]").send_keys(
  390.                     str(bachelors_major))
  391.                 browser.find_element_by_xpath("//div//div//div//div//div//div[2]//div[5]//div[1]//input[1]").send_keys(
  392.                     str(bachelors_major))
  393.  
  394.             elif masters_university is not None and bachelors_university is None:
  395.                 browser.find_element_by_xpath("//a[@class='btn btn-default add-education']").click()
  396.                 # UNIV
  397.                 browser.find_element_by_xpath("//div//div//div//div//div[2]//div[1]//div[1]//div[1]//input[2]").clear()
  398.                 browser.find_element_by_xpath(
  399.                     "//div//div//div//div//div[2]//div[1]//div[1]//div[1]//input[2]").send_keys(str(masters_university))
  400.                 # COUNTRY
  401.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[1]//div[2]//div[1]//input[1]").clear()
  402.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[1]//div[2]//div[1]//input[1]").send_keys(
  403.                     str(masters_country))
  404.                 # FROM
  405.                 browser.find_element_by_xpath(
  406.                     "//div[@id='collegediv']//div[1]//div[3]//div[1]//div[1]//input[1]").clear()
  407.                 browser.find_element_by_xpath(
  408.                     "//div[@id='collegediv']//div[1]//div[3]//div[1]//div[1]//input[1]").send_keys(str(masters_from))
  409.                 # TO
  410.                 browser.find_element_by_xpath("//div[@id='todate']//input[@placeholder='yyyy']").clear()
  411.                 browser.find_element_by_xpath("//div[@id='todate']//input[@placeholder='yyyy']").send_keys(
  412.                     str(masters_to))
  413.                 # DEGREE
  414.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[4]//div[1]//input[1]").clear()
  415.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[5]//div[1]//input[1]").clear()
  416.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[4]//div[1]//input[1]").send_keys(
  417.                     str(masters_major))
  418.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[5]//div[1]//input[1]").send_keys(
  419.                     str(masters_major))
  420.  
  421.             elif masters_university is None and bachelors_university is not None:
  422.                 browser.find_element_by_xpath("//a[@class='btn btn-default add-education']").click()
  423.                 # UNIV
  424.                 browser.find_element_by_xpath("//div//div//div//div//div[2]//div[1]//div[1]//div[1]//input[2]").clear()
  425.                 browser.find_element_by_xpath(
  426.                     "//div//div//div//div//div[2]//div[1]//div[1]//div[1]//input[2]").send_keys(
  427.                     str(bachelors_university))
  428.                 # COUNTRY
  429.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[1]//div[2]//div[1]//input[1]").clear()
  430.                 browser.find_element_by_xpath("//div[@id='collegediv']//div[1]//div[2]//div[1]//input[1]").send_keys(
  431.                     str(bachelors_country))
  432.                 # FROM
  433.                 browser.find_element_by_xpath(
  434.                     "//div[@id='collegediv']//div[1]//div[3]//div[1]//div[1]//input[1]").clear()
  435.                 browser.find_element_by_xpath(
  436.                     "//div[@id='collegediv']//div[1]//div[3]//div[1]//div[1]//input[1]").send_keys(str(bachelors_from))
  437.                 # TO
  438.                 browser.find_element_by_xpath("//div[@id='todate']//input[@placeholder='yyyy']").clear()
  439.                 browser.find_element_by_xpath("//div[@id='todate']//input[@placeholder='yyyy']").send_keys(
  440.                     str(bachelors_to))
  441.                 # DEGREE
  442.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[4]//div[1]//input[1]").clear()
  443.                 browser.find_element_by_xpath("//form//div//div//div//div//div//div[5]//div[1]//input[1]").clear()
  444.                 browser.find_element_by_xpath("//form//div//div//div//div//div[1]//div[4]//div[1]//input[1]").send_keys(
  445.                     str(bachelors_major))
  446.                 browser.find_element_by_xpath("//form//div//div//div//div//div//div[5]//div[1]//input[1]").send_keys(
  447.                     str(bachelors_major))
  448.             else:
  449.                 pass
  450.             # EMPLOYMENT
  451.             # CURRENTEMPLOYMENT
  452.             current_position = sheet.cell(row=currentRowExcel, column=9).value
  453.             current_company = sheet.cell(row=currentRowExcel, column=21).value
  454.             # CURRENT POSITION
  455.  
  456.             browser.find_element_by_xpath(
  457.                 "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[1]/input[2]").clear()
  458.             if current_position is not None:
  459.                 browser.find_element_by_xpath(
  460.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[1]/input[2]").send_keys(
  461.                     str(current_position))
  462.             else:
  463.                 browser.find_element_by_xpath(
  464.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[1]/input[2]").send_keys(
  465.                     str('N/A'))
  466.  
  467.             # CURRENTCOMPANY
  468.  
  469.             browser.find_element_by_xpath(
  470.                 "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[2]/div[1]/input[1]").clear()
  471.             if current_company is not None:
  472.                 browser.find_element_by_xpath(
  473.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[2]/div[1]/input[1]").send_keys(
  474.                     str(current_company))
  475.             else:
  476.                 browser.find_element_by_xpath(
  477.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[2]/div[1]/input[1]").send_keys(
  478.                     str('N/A'))
  479.             # FROMTO - CURRENT
  480.             browser.find_element_by_xpath(
  481.                 "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/input[1]").clear()
  482.             browser.find_element_by_xpath(
  483.                 "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").clear()
  484.             browser.find_element_by_xpath(
  485.                 "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/input[1]").send_keys(
  486.                 str('2019'))
  487.             browser.find_element_by_xpath(
  488.                 "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").send_keys(
  489.                 str('2019'))
  490.  
  491.             # OLDEMPLOYMENT
  492.             old_position = sheet.cell(row=currentRowExcel, column=32).value
  493.             old_company = sheet.cell(row=currentRowExcel, column=33).value
  494.  
  495.             if browser.find_elements_by_xpath(
  496.                     "//div[@id='employmentdiv']//div[@class='appended-employment-div']").__len__() == 1:
  497.                 # OLDPOSITION
  498.                 if old_position is not None:
  499.                     browser.find_element_by_xpath(
  500.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[2]/div[1]/div[2]/div[1]/input[1]").clear()
  501.                     browser.find_element_by_xpath(
  502.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[2]/div[1]/div[2]/div[1]/input[1]").send_keys(
  503.                         str(old_position))
  504.                 else:
  505.                     browser.find_element_by_xpath(
  506.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[2]/div[1]/div[2]/div[1]/input[1]").clear()
  507.                     browser.find_element_by_xpath(
  508.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[2]/div[1]/div[2]/div[1]/input[1]").send_keys(
  509.                         str('N/A'))
  510.                 # OLDCOMPANY
  511.                 if old_position is not None:
  512.                     if old_company is not None:
  513.                         browser.find_element_by_xpath(
  514.                             "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").clear()
  515.                         browser.find_element_by_xpath(
  516.                             "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").send_keys(
  517.                             str(old_company))
  518.                     else:
  519.                         if current_company is None:
  520.                             browser.find_element_by_xpath(
  521.                                 "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").clear()
  522.                             browser.find_element_by_xpath(
  523.                                 "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").send_keys(str('N/A'))
  524.                         else:
  525.                             browser.find_element_by_xpath(
  526.                                 "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").send_keys(
  527.                                 str(current_company))
  528.                 else:
  529.                     browser.find_element_by_xpath(
  530.                         "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").clear()
  531.                     browser.find_element_by_xpath(
  532.                         "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").send_keys(str('N/A'))
  533.                 # FROM-TO
  534.                 browser.find_element_by_xpath(
  535.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/input[1]").clear()
  536.                 browser.find_element_by_xpath(
  537.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/input[1]").send_keys(
  538.                     str('2019'))
  539.                 browser.find_element_by_xpath(
  540.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").clear()
  541.                 browser.find_element_by_xpath(
  542.                     "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").send_keys(
  543.                     str('2019'))
  544.  
  545.             else:
  546.                 # OLDPOSITION
  547.                 if old_position is not None:
  548.                     browser.find_element_by_xpath("//a[@class='btn btn-default add-work']").click()
  549.                     browser.find_element_by_xpath(
  550.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[2]/div[1]/div[2]/div[1]/input[1]").clear()
  551.                     browser.find_element_by_xpath(
  552.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[2]/div[1]/div[2]/div[1]/input[1]").send_keys(
  553.                         str(old_position))
  554.                     # OLDCOMPANY
  555.                     if old_company is not None:
  556.                         browser.find_element_by_xpath(
  557.                             "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").clear()
  558.                         browser.find_element_by_xpath(
  559.                             "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").send_keys(
  560.                             str(old_company))
  561.                     else:
  562.                         if current_company is None:
  563.                             browser.find_element_by_xpath(
  564.                                 "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").clear()
  565.                             browser.find_element_by_xpath(
  566.                                 "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").send_keys(str('N/A'))
  567.                         else:
  568.                             browser.find_element_by_xpath(
  569.                                 "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").clear()
  570.                             browser.find_element_by_xpath(
  571.                                 "//form//div//div//div//div[2]//div[1]//div[2]//div[1]//input[1]").send_keys(
  572.                                 str(current_company))
  573.                     browser.find_element_by_xpath(
  574.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/input[1]").clear()
  575.                     browser.find_element_by_xpath(
  576.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/input[1]").send_keys(
  577.                         str('2019'))
  578.                     browser.find_element_by_xpath(
  579.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").clear()
  580.                     browser.find_element_by_xpath(
  581.                         "/html[1]/body[1]/div[1]/form[1]/div[3]/div[1]/div[2]/div[1]/div[3]/div[1]/div[2]/input[1]").send_keys(
  582.                         str('2019'))
  583.                 else:
  584.                     pass
  585.             # DESCRIPTIONOFMOSTRECENTJOB
  586.             browser.find_element_by_id('job_desc').clear()
  587.             if sheet.cell(row=currentRowExcel, column=20).value is not None:
  588.                 browser.find_element_by_id('job_desc').send_keys(
  589.                     str('works at the ' + (sheet.cell(row=currentRowExcel, column=20).value)))
  590.             else:
  591.                 browser.find_element_by_id('job_desc').send_keys(str('N/A'))
  592.             # DESCRIPTIONOFMAJORAREAOFINTEREST
  593.             browser.find_element_by_id('area_interest').clear()
  594.             if sheet.cell(row=currentRowExcel, column=59).value is not None:
  595.                 browser.find_element_by_id('area_interest').send_keys(
  596.                     str(sheet.cell(row=currentRowExcel, column=59).value))
  597.             else:
  598.                 pass
  599.             # RESEARCHCARRIEDOUT
  600.             browser.find_element_by_name('research[]').clear()
  601.             if sheet.cell(row=currentRowExcel, column=35).value is not None:
  602.                 browser.find_element_by_name('research[]').send_keys(
  603.                     str(sheet.cell(row=currentRowExcel, column=35).value))
  604.             else:
  605.                 pass
  606.             browser.find_element_by_link_text('Next').click()
  607.             time.sleep(2.5)
  608.  
  609.             browser.get('https://ischo.searcaapps.org/ischo/scholarship/?d=all&p=' + str(k) + '&fr=2019&to=2021')
  610.             time.sleep(2.5)
  611.         else:
  612.             print(str(i) + ' not alumni')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement