2

I use python-binding selenium with chromedriver. I use webdriverwait until expected condition of an element is not displayed

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec

    def view_journal_entry(self):
        self.driver.refresh()
        self.driver.find_element_by_css_selector('a.small_journal_link.get-ajax-account-transaction').click()
        try:
            WebDriverWait(self.driver, 10).until(
                ec.invisibility_of_element_located((By.CSS_SELECTOR, 'div.blinkdot')))
        finally:
            pass

    def check_journal_entry(self):
        self.view_journal_entry()
        debit = self.driver.find_element_by_css_selector('td.gl_total_debit').get_attribute('innerHTML')
        credit = self.driver.find_element_by_css_selector('td.gl_total_credit').get_attribute('innerHTML')
        index = 0
        while ((debit != credit) or (debit == '0,00') or (credit == '0,00')) and index < 2:
            self.view_journal_entry()
            index += 1
        if (debit == credit) and (debit != '0,00') and (credit != '0,00'):
            print('debit is ' + debit + '\n' + 'credit is ' + credit)
            print('journal entry is balanced \n')
            self.driver.refresh()
        elif (debit == '0,00') or (credit == '0,00'):
            print('debit or credit is 0, please check sidekiq \n')
            self.driver.refresh()
        else:
            print('debit is ' + debit + '\n' + 'credit is ' + credit)
            print('journal entry is not balanced \n')
            self.driver.refresh()

The problem is the webdriver does not wait for the element to be not displayed until the timeout, and the only thing I need is to change normal refresh into refresh bypass cache so that the element is not displayed when I loop the function.

How do you refresh bypass cache using python selenium with chromedriver?

gara
  • 21
  • 3
  • Can you tell us a bit more about: 1) your _usecase_ 2) _HTML_ of the element, 3) why you want to `wait for the element to be not displayed ` and 4) your next steps once the `element is not displayed` – undetected Selenium May 25 '18 at 07:01
  • I want to loop `self.view_journal_entry()` until the `div.blinkdot` is invisible. That element might become invisible and `td.gl_total_debit` and `td.gl_total_credit` are loaded if webdriver waits, but in some cases I need to manually refresh bypass the cache if the wait doesn't work. `self.driver.refresh()` failed and `div.blinkdot` is still visible, and `td.gl_total_debit` and `td.gl_total_credit` are not loaded – gara May 25 '18 at 07:59

0 Answers0