Jul-21-2022, 11:35 AM
you didn't explain which package you are using I will assume selenium for this response:
instead of using sleep for a specified amount of time, use WebDriverWait and wait until presense of
something which changes after your submission.
Advantage is that the delay will only last as long as necessary, so you can make it larger.
If you do this, the longer delay will only occur if necessary
In the following example (see: https://selenium-python.readthedocs.io/waits.html ):
'delay' variable was set during class initialization to 30, usually only uses less than one second, and as mentioned the selenium driver will only use the necessary time, then continue
i am expecting the text to show up in element see 'Expected Conditions' on above webpage.
see: ( https://selenium-python.readthedocs.io/a...nt_located
i wait for an element using CSS_SELECTOR there are several choices.
Here it's waiting for display of page number text: 'Page 1 of 1, records 1 to 1 of 1' or similar.
Rarely fails.
Example:
instead of using sleep for a specified amount of time, use WebDriverWait and wait until presense of
something which changes after your submission.
Advantage is that the delay will only last as long as necessary, so you can make it larger.
If you do this, the longer delay will only occur if necessary
In the following example (see: https://selenium-python.readthedocs.io/waits.html ):
'delay' variable was set during class initialization to 30, usually only uses less than one second, and as mentioned the selenium driver will only use the necessary time, then continue
i am expecting the text to show up in element see 'Expected Conditions' on above webpage.
see: ( https://selenium-python.readthedocs.io/a...nt_located
i wait for an element using CSS_SELECTOR there are several choices.
Here it's waiting for display of page number text: 'Page 1 of 1, records 1 to 1 of 1' or similar.
Rarely fails.
Example:
element = WebDriverWait(self.browser, delay).until( \ EC.presence_of_element_located((By.CSS_SELECTOR, '#txtCommonPageNo')))