1

I've written a selenium program to search specific keywords using google. But I found that it always waits for the page to load, sometimes it waits too long, and the page seems to be stuck there. Then my program stopped there with a timeout exception. as my code shows below:

ActionChains(driver).send_keys_to_element(input, keyword).send_keys(Keys.ENTER).perform()
driver.switch_to.window(main_window)

I need when the google page gets the keyword into the input area, maybe 1 or 2 seconds later, the program will go on to the next step the get another keyword from the main window. I've tried the implicit or explicit wait, but I don't want to deal with the exception, I don't want the exception to interrupt my program, I don't mind if several pages have been completely executed.

How to set it up?

Dave Yu
  • 315
  • 4
  • 15
sampan0423
  • 89
  • 6
  • my problem is I need to set a restrict time, for example, 10 sec, if the page is running smoothly, the program will jump to next step automatically maybe in just 1 or 2 sec, but when the page is stuck, the time is uncertain, maybe 20sec, maybe 30, or even timed out, and program is over. – sampan0423 Nov 30 '21 at 03:27

0 Answers0