Using with python selenium WebDriverWait in pysaunter for async pages?
Question: I'm trying to code nicely against a web site with AJAX like functionality, and
using pysaunter (<http://element34.ca/products/saunter/pysaunter>).

When I use the available synchronization method wait_for_available, perhaps
improperly, my code does more or less what I want, but the Selenium server
node throws asserts like following while the class is not yet present:

> org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to
> locate element: {"method":"css selector","selector":".ng-scope.ready.idle"}

I'd like to use WebDriverWait, I think like this:

    
    
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    WebDriverWait(self.driver, 30).until(EC.presence_of_element_located((By.CLASS_NAME,'idle')))
    

But when I try that, I still get the above exception from a Firefox remote
webdriver, and the following from a chrome remote webdriver:

> 13:09:22.525 WARN - Exception: no such element (Session info:
> chrome=29.0.1547.76) (Driver info: chromedriver=2.0,platform=Mac OS X 10.8.5
> x86_64) (WARNING: The server did not provide any stacktrace information)

Is it possible to avoid exceptions from Selenium Server when looking for an
element that will likely not be present right away, when running remote
webdriver using Python?

Can anyone point me to an example of the proper way to use WebDriverWait from
pysaunter? I'm starting from here:
<http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp> and (see also
Element 34 blog posting "WebDriverWait and Python" from July 9th, 2012)

TIA


Answer: If you look into the WebDriverWait code you will see that you can give the
constructor a list of exceptions to ignore. One such list is pre-defined,
'IGNORED_EXCEPTIONS', that is set to [NoSuchElementException]. So you can just
add 'ignored_exceptions=IGNORED_EXCEPTIONS' to the WebDriverWait constructor,
i.e.:

    
    
    WebDriverWait(self.driver, 30, ignored_exceptions=IGNORED_EXCEPTIONS).until(...)
    

Then those exceptions will be ignored and it will continue to try until it
succeeds or times out.

