Description:
I submit a form, and some times the server takes too long to respond. If you open the DevTools, in the network tab you can see the request on pending status.
*** Keywords ***
Download Information
[Arguments] ${type}
Input text id:type ${type}
Submit Form
Question:
How can I put some timeout on this action, to limit how long the robot should wait?
Thank you for you answer!!
I Already try Set Selenium Timeout, but it doesn’t work.
This is what I’ve tried:
*** Keywords ***
Download Information
[Arguments] ${type}
Input text id:type ${type}
Set Selenium Timeout 20 seconds
Submit Form
Log To Console It should fail if it takes more than 20 seconds to reach this line
But it took 60 seconds and the Keywords did not fail
*** Keywords ***
Download Information
[Arguments] ${type}
Input text id:type ${type}
Set Selenium Timeout 20 seconds
Submit Form
Log To Console It should log right after submit form
Wait Until Location Is ${the_url_tha_comes_with_the_requested_info} timeout=10
But it took 60 second to Log To Console be executed
The problem is that I want to limit the time that the robot should take to complete this task, if this task reach the timeout it must go to the next step. Some thing like this:
*** Keywords ***
Download Information
[Arguments] ${type}
Input text id:type ${type}
Set Selenium Timeout 20 seconds
Submit Form
Log To Console It should log right after submit form
[Teardown] Log If Fails ${type}
*** Keywords ***
Log If Fails
[Arguments] ${type}
IF '${KEYWORD_STATUS}' == 'FAIL'
Log To Console The type: ${type} Fail!!
END
*** Tasks ***
@{list}= Create List word excel teams
FOR ${type} IN @{list}
Run Keyword And Continue On Failure Download Information ${type}
END
The result I expect is:
All the types in the list should be executed
Any type that takes more than 20 seconds should be log to the console
Continuing from Raivo’s suggestion. Is there something that happens always after you submit the form, for example, a certain element appears after the submit (if the submit succeeds)?
So, maybe submit the form, then call one of the “wait until something” keywords (using a suitable timeout). At least to see if those respect the given timeout better.
Thank you for your answer.
There is a button to cancel the operation, as soon as I submit the form.
But as show here the code below the submit form get executed only after the server response.
If you want to act based on outcome maybe try Run Keyword And Ignore Error then you can use status to decide what do perform next.
Example from my robot:
${success} Run Keyword And Ignore Error Send Mail To Vendor With Invoice
... ${vendor_email}
... ${invoice_number}
... ${ticket_number}
... ${ticket_sys_id}
... ${attachment_name}
... ${filepath}
IF '${success[0]}' == 'PASS'
Update Ticket Information On Success ${ticket_sys_id}
ELSE
Update Ticket Information On Failure ${ticket_sys_id}
Fail Failed to send email
END
EDIT: Missed the response part after submit form, then like @jani mentioned click action is worth to try.
Yes, it strange. I’ve tried with Click Element, Click Link. But I get the same behavior, the execution get stacked to the Click until the server responds.
*** Keywords ***
Download Information
[Arguments] ${type}
Input text id:type ${type}
Set Selenium Timeout 20 seconds
Click Element xpath://button[@type='submit']
Log To Console It should log right after submit form
Wait Until Location Is ${the_url_tha_comes_with_the_requested_info} timeout=10
*** Keywords ***
Download Information
[Arguments] ${type}
Input text id:type ${type}
Set Selenium Timeout 20 seconds
Click Link xpath://button[@type='submit']
Log To Console It should log right after submit form
Wait Until Location Is ${the_url_tha_comes_with_the_requested_info} timeout=10
Thanks for that, that keyword(Run Keyword And Ignore Error) will be useful for me. But I think I should change my strategy to handle my this use case, because, in the documentation they explain that the timeout error will not be catch by this keyword.