For situations I know there can be interference, I wrap the call in wrapper function that retries the call over and over again until a timeout or success. I'm using python, so i can pass it a lamba function.
def wait_until(function, timeout=TIMEOUT_MANAGER.NORMAL, sleep=0.5):
Waits until URL matches the expression.
@param condition: Lambda expression to wait on. Lambda expression
should return true when conditions is met.
@type function: lambda
@param timeout: Timeout period in seconds.
end_time = datetime.now() + timedelta(seconds = timeout)
while datetime.now() < end_time:
except Exception as e:
raise OperationTimeoutError("Operation timed out.")
click_submit = lambda: webdriver.find_element_by_css_selector(".submit").click()
With Java, this pattern is slightly harder to do, you'll have to define an Interface, and pass in an anonymous inner class.