start2 = datetime.datetime.now()

button8 = driver.find_element_by_xpath("//span[contains(text(),'Last Month')]").click()

timeout = time.time() + 60 * 2
while len(driver.find_elements_by_css_selector("path[class='area areaChart']")) != 16:
    if time.time() > timeout:
print('Last month option selected')
elapsed2 = datetime.datetime.now()
x = elapsed2 - start2
#print("Elapsed Time2 = {0}".format(elapsed2 - start2))
#if x <= 5:
assert (x <= 5),"VM4 is working good!"
  • 2
    Note that Selenium is not a reliable performance testing tool. – João Farias Jul 10 '19 at 7:11

You can go for WebDriver.set_page_load_timeout() function, if page loading time will be exceeded - Selenium will throw an error automatically.


You can also use Explicit Wait instead of your construction:

wait(driver, 5).until(lambda driver: len(driver.find_elements_by_css_selector("path[class='area areaChart']")) != 16)

More information: How to use Selenium to test web applications using AJAX technology

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.