Beispiel #1
0
	def openMenu(self):
		self.is_idle = False
		self.openPage()
		print('PEB - Open menu..')

		# Klik menu informasi
		menuInformasi = self.driver.find_element_by_xpath('//button[@class = "z-menu-btn" and contains(., "Informasi")]')
		menuInformasi.click()

		# Klik submenu Cetak dan Kirim Ulang Respon
		checkMenuRespon = EC.presence_of_element_located((By.XPATH, '//ul[@class = "z-menu-popup-cnt"]//a[.= " Cetak dan Kirim Ulang Respon"]'))
		WebDriverWait(self.driver, 30).until(checkMenuRespon)

		menuRespon = self.driver.find_element_by_xpath('//ul[@class = "z-menu-popup-cnt"]//a[.= " Cetak dan Kirim Ulang Respon"]')
		menuRespon.click()
		pre.waitLoading(self.driver)

		# Pilih filter car
		checkFilter = EC.presence_of_element_located((By.XPATH, '//div[@class = "z-tabpanels"]/div[@class = "z-tabpanel"][1]//input[@class = "z-combobox-inp z-combobox-readonly"]'))
		WebDriverWait(self.driver, 120).until(checkFilter)

		dropFilter = self.driver.find_element_by_xpath('//div[@class = "z-tabpanels"]/div[@class = "z-tabpanel"][1]//input[@class = "z-combobox-inp z-combobox-readonly"]')
		dropFilter.click()

		optionCar = self.driver.find_element_by_xpath('//td[@class = "z-comboitem-text" and contains(., "Car")]')
		optionCar.click()

		checkInputAju = EC.presence_of_element_located((By.XPATH, '//div[@class = "z-tabpanels"]/div[@class = "z-tabpanel"][1]//input[@class = "z-textbox" and @maxlength="26"]'))
		WebDriverWait(self.driver, 120).until(checkInputAju)

		self.is_idle = True
Beispiel #2
0
    def kosongkanData(self, tab):
        tabNum = {'PIB': '1', 'PROSES': '3'}

        btnKosongkan = self.driver.find_element_by_xpath(
            f'//div[@class = "z-tabpanels"]/div[{tabNum[tab]}]//td[@class = "z-button-cm" and .= "Kosongkan"]'
        )
        btnKosongkan.click()
        time.sleep(1)
        pre.waitLoading(self.driver, 120)
Beispiel #3
0
    def checkAju(self, noAju, tab):
        colNum = {'PIB': '5', 'PROSES': '3'}

        try:
            errorBox = ''
            errorBox = self.driver.find_element_by_xpath(
                '//div[contains(@class, "z-messagebox")]/span[contains(@class, "z-label") and contains(., "Unknown exception")]'
            )
            while 'errorBox' != '':
                self.getResponses(tglAwal, noAju)
        except NoSuchElementException:
            try:
                boxNotFound = self.driver.find_element_by_xpath(
                    '//div[@class = "z-window-modal-cnt" and //span[@class = "z-label" and .= "Data Tidak Ditemukan"]]'
                )
            except NoSuchElementException:
                txtAju = noAju[:6] + '-' + noAju[6:12] + '-' + noAju[
                    12:20] + '-' + noAju[20:]
                xpathRowAju = f"//div[@class='z-listbox-body']//tr[contains(@class,'z-listitem')][.//td[{colNum[tab]}]/div[@class='z-listcell-cnt z-overflow-hidden'][text()='{txtAju}']]"
                checkRowAju = EC.element_to_be_clickable(
                    (By.XPATH, xpathRowAju))
                rowAju = WebDriverWait(self.driver, 5).until(checkRowAju)
                colsHeader = rowAju.find_elements_by_css_selector('td > div')

                if tab == 'PIB':
                    tglPib = colsHeader[0].get_attribute('innerHTML')
                    noPib = colsHeader[1].get_attribute('innerHTML')
                    self.updateStatus(f'PIB no {noPib} tgl {tglPib} ditemukan')

                    importir = colsHeader[2].get_attribute('innerHTML')
                    ppjk = colsHeader[3].get_attribute('innerHTML')
                elif tab == 'PROSES':
                    self.updateStatus(f'PIB aju {noAju} ditemukan')

                    importir = colsHeader[0].get_attribute('innerHTML')
                    ppjk = colsHeader[1].get_attribute('innerHTML')

                perusahaan = ppjk if ppjk != '-' else importir
                self.updateRequest(perusahaan)

                self.driver.execute_script('arguments[0].click()', rowAju)
                time.sleep(.5)
                pre.waitLoading(self.driver)

                return True
            else:
                btnOkNotFound = self.driver.find_element_by_xpath(
                    '//div[@class = "z-window-modal-cnt" and //span[@class = "z-label" and .= "Data Tidak Ditemukan"]]//td[@class = "z-button-cm" and .= "OK"]'
                )
                btnOkNotFound.click()
                pre.waitLoading(self.driver)
                return False
Beispiel #4
0
    def openMenu(self):
        self.is_idle = False
        self.openPage()

        print('Open menu..')
        menuUtility = self.driver.find_element_by_css_selector(
            '.z-menu:nth-child(4) button')
        menuUtility.click()

        menuRespon = self.driver.find_element_by_css_selector(
            '.z-menu-popup li:nth-child(1) a')
        menuRespon.click()

        pre.waitLoading(self.driver)
        self.is_idle = True
Beispiel #5
0
    def openMenu(self):
        self.is_idle = False
        self.openPage()

        print('Open menu..')
        menuUtility = self.driver.find_element_by_xpath(
            '//button[@class = "z-menu-btn" and contains(., "Utility")]')
        menuUtility.click()

        checkMenuBrowse = EC.presence_of_element_located(
            (By.XPATH,
             '//ul[@class = "z-menu-popup-cnt"]//a[.= " Browse Respon"]'))
        WebDriverWait(self.driver, 30).until(checkMenuBrowse)

        menuRespon = self.driver.find_element_by_xpath(
            '//ul[@class = "z-menu-popup-cnt"]//a[.= " Browse Respon"]')
        menuRespon.click()

        pre.waitLoading(self.driver)
        self.is_idle = True
Beispiel #6
0
    def findPib(self, tglAwal, tglAkhir, noAju):
        print(f'PIB [ID:{self.req_id}] - finding PIB..')
        tab = 'PIB'
        tabPib = self.driver.find_element_by_xpath(
            '//span[@class = "z-tab-text" and .= "PIB"]')
        tabPib.click()
        pre.waitLoading(self.driver)
        checkHeaderPib = EC.visibility_of_element_located(
            (By.XPATH,
             "//div[@class='z-window-embedded-header'][text()='PIB']"))
        WebDriverWait(self.driver, 5).until(checkHeaderPib)

        self.inputAju(noAju, tab)
        self.inputTanggal(tglAwal, tglAkhir, tab)
        self.tampilkanData(tab)
        pibFound = self.checkAju(noAju, tab)
        if pibFound:
            self.chooseResponses(tab)
            self.kosongkanData(tab)
        else:
            self.findProses(tglAwal, tglAkhir, noAju)
Beispiel #7
0
    def sendResponses(self, response, tab):
        print(f'PIB [ID:{self.req_id}] - Send response {response}..')
        tabNum = {'PIB': '1', 'PROSES': '3'}

        try:
            xpathBtnKirim = f"//div[@class = 'z-tabpanels']/div[{tabNum[tab]}]//div[@class = 'z-listbox'][2]//tbody[contains(@id, 'rows')]/tr[.//td[3]/div[text()='{response}']]//td[@class='z-button-cm'][text()='Kirim']"
            checkBtnKrm = EC.element_to_be_clickable((By.XPATH, xpathBtnKirim))
            btnKrm = WebDriverWait(self.driver, 30).until(checkBtnKrm)
        except TimeoutException as e:
            print(
                f'PIB [ID:{self.req_id}] - GAGAL MENDAPATKAN TOMBOL KIRIM {e}')
            self.updateStatus(f'Gagal kirim respon. Coba beberapa saat lagi.',
                              True)
        except Exception as e:
            print(f'PIB [ID:{self.req_id}] - ERROR {e}')
            self.updateStatus(f'Gagal kirim respon. Coba beberapa saat lagi.',
                              True)
            self.is_alive = False
        else:
            btnKrm.click()
            try:
                xpathBtnOk = "//div[@class='z-window-modal z-window-modal-shadow'][.//span[text()='Kirim Ulang Berhasil Dilakukan']]//td[@class='z-button-cm'][text()='OK']"
                checkBtnOk = EC.element_to_be_clickable((By.XPATH, xpathBtnOk))
                btnOk = WebDriverWait(self.driver, 30).until(checkBtnOk)
            except TimeoutException as e:
                print(
                    f'PIB [ID:{self.req_id}] - GAGAL MENDAPATKAN TOMBOL KONFIRMASI {e}'
                )
                self.updateStatus(
                    f'Gagal kirim respon. Coba beberapa saat lagi.', True)
            except Exception as e:
                print(f'PIB [ID:{self.req_id}] - ERROR {e}')
                self.updateStatus(
                    f'Gagal kirim respon. Coba beberapa saat lagi.', True)
                self.is_alive = False
            else:
                btnOk.click()
                pre.waitLoading(self.driver)
                pre.waitModalClose(self.driver)
                self.updateStatus(f'{response} berhasil dikirim')
Beispiel #8
0
    def findProses(self, tglAwal, tglAkhir, noAju):
        print(f'PIB [ID:{self.req_id}] - finding PIB tab PROSES..')
        tab = 'PROSES'
        tabProses = self.driver.find_element_by_xpath(
            '//span[@class = "z-tab-text" and .= "PROSES"]')
        tabProses.click()
        pre.waitLoading(self.driver)
        checkHeaderProses = EC.visibility_of_element_located(
            (By.XPATH,
             "//div[@class='z-window-embedded-header'][text()='Proses']"))
        WebDriverWait(self.driver, 5).until(checkHeaderProses)

        self.inputAju(noAju, tab)
        self.inputTanggal(tglAwal, tglAkhir, tab)
        self.tampilkanData(tab)
        pibFound = self.checkAju(noAju, tab)
        if pibFound:
            self.chooseResponses(tab)
            self.kosongkanData(tab)
        else:
            msg = 'Aju tidak ditemukan'
            is_end = True
            self.updateStatus(msg, is_end)
Beispiel #9
0
    def openMenu(self):
        # Klik menu browse
        xpathMenuBrowse = "//td[@class='z-menu'][.//button[@class='z-menu-btn'][text()='Browse\u00a0']]"
        checkMenuBrowse = EC.element_to_be_clickable(
            (By.XPATH, xpathMenuBrowse))
        menuBrowse = WebDriverWait(self.driver, 30).until(checkMenuBrowse)
        menuBrowse.click()
        pre.waitLoading(self.driver)

        # Klik menu kirim ulang
        xpathMenuKirimUlang = "//div[@class='z-menu-popup z-menu-popup-shadow']//li[@class='z-menu-item'][.//a[@class='z-menu-item-cnt'][text()=' Browse Cetak Kirim Ulang Semua Respon']]"
        checkMenuKirimUlang = EC.element_to_be_clickable(
            (By.XPATH, xpathMenuKirimUlang))
        menuKirimUlang = WebDriverWait(self.driver,
                                       30).until(checkMenuKirimUlang)
        menuKirimUlang.click()
        pre.waitLoading(self.driver)

        # Check page
        xpathHeader = "//div[@class='z-window-embedded-header'][text()='BROWSE DAN CETAK SEMUA RESPON']"
        checkHeader = EC.presence_of_element_located((By.XPATH, xpathHeader))
        WebDriverWait(self.driver, 30).until(checkHeader)

        # Pilih filter car
        xpathFilterType = "(//input[@class='z-combobox-inp z-combobox-readonly'])[1]"
        checkFilterType = EC.element_to_be_clickable(
            (By.XPATH, xpathFilterType))
        dropdownFilterType = WebDriverWait(self.driver,
                                           5).until(checkFilterType)
        dropdownFilterType.click()

        xpathItemFilterType = "//div[@class='z-combobox-pp z-combobox-shadow']//tr[@class='z-comboitem'][.//td[@class='z-comboitem-text'][text()='Car\u00a0\u00a0\u00a0\u00a0:']]"
        checkItemFilterType = EC.element_to_be_clickable(
            (By.XPATH, xpathItemFilterType))
        itemFilterType = WebDriverWait(self.driver,
                                       5).until(checkItemFilterType)
        self.driver.execute_script('arguments[0].click()', itemFilterType)
        pre.waitLoading(self.driver)

        xpathInputAju = "//input[contains(@class, 'z-textbox')][@maxlength='26']"
        checkInputAju = EC.presence_of_element_located(
            (By.XPATH, xpathInputAju))
        WebDriverWait(self.driver, 30).until(checkInputAju)
Beispiel #10
0
	def find_peb(self, tglAwal, tglAkhir, noAju):
		tabPeb = self.driver.find_element_by_xpath('//span[@class = "z-tab-text" and .= "PEB"]')
		tabPeb.click()

		inputTglAwal, inputTglAkhir = self.driver.find_elements_by_xpath('//div[@class = "z-tabpanels"]/div[@class = "z-tabpanel"][1]//input[@class = "z-datebox-inp"]')

		# Handling input tgl akhir
		inputTglAkhir.clear()
		inputTglAkhir.click()
		self.driver.execute_script('arguments[0].value = arguments[1]', inputTglAkhir, tglAkhir)
		inputTxt = self.driver.find_element_by_css_selector('.z-textbox')
		inputTxt.click()

		# Handling input tgl awal
		inputTglAwal.clear()
		inputTglAwal.click()
		self.driver.execute_script('arguments[0].value = arguments[1]', inputTglAwal, tglAwal)
		inputTxt = self.driver.find_element_by_css_selector('.z-textbox')
		inputTxt.click()

		# Handling filter no aju
		inputAju = self.driver.find_element_by_xpath('//div[@class = "z-tabpanels"]/div[@class = "z-tabpanel"][1]//input[@class = "z-textbox" and @maxlength="26"]')
		self.driver.execute_script('arguments[0].value = arguments[1]', inputAju, noAju)
		inputAju.click()

		# Klik tampilkan
		btnTampilkan = self.driver.find_element_by_xpath('//td[@class = "z-button-cm" and .= "Tampilkan"]')
		btnTampilkan.click()

		time.sleep(1)
		pre.waitLoading(self.driver, 120)
		try:
			errorBox = ''
			errorBox = self.driver.find_element_by_xpath('//div[contains(@class, "z-messagebox")]/span[contains(@class, "z-label") and contains(., "Unknown exception")]')
			while 'errorBox' != '':
				self.getResponses(tglAwal, noAju)
		except NoSuchElementException:
			try:
				boxNotFound = self.driver.find_element_by_xpath('//div[@class = "z-window-modal-cnt" and //span[@class = "z-label" and .= "Data Tidak Ditemukan"]]')
			except NoSuchElementException:
				noAjuDash = noAju[:6] + '-' + noAju[6:12] + '-' + noAju[12:20] + '-' + noAju[20:]
				rowPeb = self.driver.find_element_by_xpath(f'//div[@class = "z-listbox"][1]//tbody[contains(@id, "rows")]/tr[contains(@class, "z-listitem") and //div[@class = "z-listcell-cnt" and .= "{noAjuDash}"]]')

				colsHeader = rowPeb.find_elements_by_css_selector('td > div')
				noPeb = colsHeader[0].get_attribute('innerHTML')
				tglPeb = colsHeader[1].get_attribute('innerHTML')
				eksportir = colsHeader[2].get_attribute('innerHTML')
				ppjk = colsHeader[3].get_attribute('innerHTML')
				perusahaan = ppjk if ppjk != '-' else eksportir

				self.updateStatus(f'PEB no {noPeb} tgl {tglPeb} ditemukan')

				self.driver.execute_script('arguments[0].click()', rowPeb)
				time.sleep(.5)
				pre.waitLoading(self.driver)

				rows = self.driver.find_elements_by_xpath('//div[@class = "z-listbox"][2]//tbody[contains(@id, "rows")]/tr')
				self.updateRequest(perusahaan)
				self.chooseResponses(rows)
			else:
				btnOkNotFound = self.driver.find_element_by_xpath('//div[@class = "z-window-modal-cnt" and //span[@class = "z-label" and .= "Data Tidak Ditemukan"]]//td[@class = "z-button-cm" and .= "OK"]')
				btnOkNotFound.click()
				msg = 'Aju tidak ditemukan atau belum mendapat respon NPE/PPB'
				is_end = True
				self.updateStatus(msg, is_end)
				pre.waitLoading(self.driver)