python selenium - takes a lot of time when it does not find elements

Viewed 1422

my code scans a lot of internet pages with chromedriver and searches for the same element in each page with "find_elements_by_xpath"

Lines = driver.find_elements_by_xpath(
                    '//*[@id="top"]/div[contains(@style, "display: block;")]/'
                    'div[contains(@style, "display: block;")]//tbody//a[contains(@title, "Line")]')

When it finds, one or multiple, it works fast and good. But, when the XPath doesn't exist it runs for 6-7 seconds and then moves on.

Can I limit the search for 1 second, And if it doesn't find in a second, just move on? Is there a way to do this?

1 Answers
Related