0

After submitting the request, there are two possible options:

  1. The request cannot be executed and a notification about the rejection of the request will appear

  2. The request can be executed and a button will appear to confirm the request. Now the implementation is as follows, try waits for a rejection notification, and if not executed by timeout, then except looks for a request confirmation button. The disadvantage of this approach is that it takes 10 minutes to process the request. And if the button for confirming the request appears at 5 seconds, then all the same there will be a 10 minute wait for the notification about the rejection of the request, we lose time. I saw on the Internet the approach of waiting for two elements through the lambda functions of Python, but I could not figure out what and how. Can someone help? or suggest alternative solutions to the problem

     def reject_request(self):
     id_pending = self._get_element_text(Main.pending_locates.pending_id)
    
     try:
         self._wait_for_visible(Main.pending_locates.reject_window)
         id_result = self._get_element_text(Main.results.result_id)
    
         assert id_pending == id_result, 'The ID of the request is not found in the result table'
         print('Your request automatically rejected')
    
     except TimeoutException:
         self._click(Main.pending_locates.button_reject)
         sleep(1)
         id_result = self._get_element_text(Main.results.result_id)
    
         assert id_pending == id_result, 'The ID of the request is not found in the result table'
         print('Your request manually Rejected')
     return self
    

I want to implement it in a way similar to this, but I have little experience. If anyone can help I will explain in more detail

  • Without your code it is hard to point out where is the error. What I would do is set up an `xpath` which is `True` if any of the given elements is present. Then `WebDriverWait(driver,10).until...` if a `for` loop with a timeout and done. – Trapli Feb 01 '21 at 13:54
  • @Trapli I'm sorry I didn't make my problem clear. I have no problems implementing 'try except'. this code works. but I have to set a very long 'wait = 600', and this may take extra time because the second condition will happen faster than the condition with 'try' – Anatolii Olesh Feb 01 '21 at 15:29

0 Answers0