0
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:
    time.sleep(0.1)
    if time.time() > timeout:
         break
print('Last month option selected')
elapsed2 = datetime.datetime.now()
x = elapsed2 - start2
print(x)
#print("Elapsed Time2 = {0}".format(elapsed2 - start2))
#if x <= 5:
assert (x <= 5),"VM4 is working good!"
  • Note that Selenium is not a reliable performance testing tool. – João Farias Jul 10 at 7:11
0

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

driver.set_page_load_timeout(5)

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

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.