Exception handling in Paypal checkout where not able to access id of iframe element

前端 未结 1 1557
失恋的感觉
失恋的感觉 2021-01-26 02:37

I have an eCommerce website where, when I try to place an Order where it redirects to a Paypal Page. When I Login as a Paypal user, it redirects to another checkout screen where

相关标签:
1条回答
  • 2021-01-26 03:13

    In this situations problem might be one of the two below reasons.

    1.If its redirecting to new window and without switching to new window you cannot access any locator of new window. You can use the below code to switch window

     String Parent_Window = driver.getWindowHandle(); 
     //Get Parent window handle befor child window opens
     String winHandleBefore = _driver.getWindowHandle();
     for (String winHandle : _driver.getWindowHandles()) {
       // Switch to child window
       if( Parent_Window != winHandle )
       driver.switchTo().window(winHandle);
     }
    

    Perform the action in child window and switch back to parent window.

    1. If it is not redirecting to new window and your locator is correct then the problem might be that , frame you are looking for is the child of some other frame. In that case you may have to switch to parent frame first and then to child frame.

    Hope this will work.

    0 讨论(0)
提交回复
热议问题