tebelorg / RPA-Python

Python package for doing RPA
Apache License 2.0
4.96k stars 670 forks source link

About wait method - set timeout() threshold to auto-wait for element to appear #537

Closed fengzstrong closed 3 months ago

fengzstrong commented 3 months ago

Hi, kensoh. Thanks for your great jobs.

I've encountered some issues, as follows.

When using RPA-Python to handle websites, the time it takes for a site to fully load is uncertain. How can I wait until the website is completely loaded before proceeding to the next step? The wait function appears to only wait for a fixed duration, which does not satisfy my requirements.

Any help would be greatly appreciated.

kensoh commented 3 months ago

Thanks @fengzstrong you can try using r.timeout() to set how long to wait. For eg r.timeout(300) to wait for 5 minutes. Before the r.click() or r.type() step you do times out.

kensoh commented 3 months ago

Another example is below, it will wait up to 5 minutes for the web element something to appear, before continuing.

r.timeout(300) r.hover(something) rest of steps

fengzstrong commented 3 months ago

@kensoh

If the page loads quickly, then I only need to wait a few milliseconds. If there's a lot of network latency, then I'll wait for 5 minutes before timing out. Is that correct? Sorry, I should have tested it myself.

kensoh commented 3 months ago

Yes, each step click() type() and so on will auto wait for element to come out before it times out. Default is 10 seconds but you can change with timeout()