HENNGE / arsenic

Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Other
350 stars 54 forks source link

timeouts #2

Closed tarekziade closed 7 years ago

tarekziade commented 7 years ago

The wait function can probably use the built-in wait_for() code to simplify the code and be more efficient

https://github.com/ojii/arsenic/blob/6e381a153e4acf815f4b1b862cce2bede54f1406/src/arsenic/webdriver.py#L218-L234

https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for

tarekziade commented 7 years ago

on a second though, I think it would be more elegant to include in all APIs an optional timeout value. e.g.

h1 = await firefox.get_element('h1', timeout=5)

That'd raise something in case the result did not come back after 5 seconds.

ojii commented 7 years ago

h1 = await firefox.get_element('h1', timeout=5)

I've added session.wait_for_element(timeout, selector) and session.wait_for_element_gone(timeout, selector) because those are the two most used ones.

I'm specifically not using asyncio.wait_for because I still hope to keep this "async-framwork-agnostic" (waiting/timeouts work different in tornado).

tarekziade commented 7 years ago

sounds good!