0

I have this code and how to loop if load timeout it will return except and it run next test case

def search_action(self, xpath, value):

    try:
        self.driver.set_page_load_timeout(1)
        element = self.driver.find_element(By.XPATH, xpath)
        element.send_keys(value)
        element.send_keys(Keys.ENTER)
    except TimeoutException as e:
        print('EXCEPT', e)
        pass

    print('success')


se = class_name()


for domain in config['list_domain']:
    se.get_domain(domain)
    for i in range(1, 100):
        xpath = config[domain]['list_test']['search']
        se.search_action(xpath, i)
        se.get_domain(domain)

return:

selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 0.319

I want loop from 1 to 100 i don't want return error

1 Answer 1

0

I guess your problem is not with set_page_load_timeout.
You need to use WebDriverWait expected_conditions to wait for element to become clickable.

wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))

Since you did not share link and xpath details I can't give more detailed answer here.

Sign up to request clarification or add additional context in comments.

2 Comments

i.e. i want to set timeout 10 if it exceeds the time it returns an exception and it runs the next loop
important i don't want to stop the loop i want to finish it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.