1

By using selenium with IE 11 and Python 3.6.3, need to download Excel and PDF files from Website with selenium:

  1. click download button
  2. send keys S to save file
  3. click other button to download

When I execute the third step, my code was stuck without any exception.

Key Code:

def _click_excel(self):

    for i in range(self.retry_times):
        try:

            self.wait.until(EC.element_to_be_clickable((By.LINK_TEXT, 'Excel Download'))).click()
            return ErrCode.add(ErrCode.SUCCESS)

        except Exception as err:
            logger.error("statement  error:{}".format(err))

    return ErrCode.add(ErrCode.CURRENT_MENU_HAS_CHANGED, "statement  error")

def _send_save_keys():
    # send  ALT + S 

    # statements

def _click_view(self, item, inner_height):
    for i in range(self.retry_times):
        try:

            xpath = '//a[@id="rq{}"]'
            self.wait.until(EC.element_to_be_clickable((By.XPATH, xpath.format(item)))).click

            return ErrCode.add(ErrCode.SUCCESS)

        except Exception as err:
            logger.error("statement  error:{}".format(err))

    return ErrCode.add(ErrCode.CURRENT_MENU_HAS_CHANGED, "statement  error")
xiehongguang
  • 1,274
  • 1
  • 10
  • 24

0 Answers0