"switchToWindowTitle()" Script Order Changes

In our application, we have “Select Staff” button in Record Request(Parent Window) Page , if we click the “Select Staff” button a new popup window as another window screen (as child window)

Please find the Application Screenshot:

While recording test case,

  1. we have clicked select staff Button , a new child window is opened .
  2. In new child window we are performing some operation .

Please find Test script generation for above actions…

FYI, we are facing two kind of issue from the above generated Script ,

  1. Expected child window name is “Staff Search” but the script actually generating window name as Record Request which as Parent window name .

Parent window title name : “Record Request”
Child window title name : “Staff Search”

  1. “switchToWindowTitle()” method is generated before the click action (Clicking select staff Button )performed for “clicking select staff” button

Please guide me to find the solution so that script need not to be changed once recording is done!

Is there anything stopping you from simply changing the lines order? I dont see a reason for it recording the click after but if it is recording it that way then all you will have to do to resolve this is switch the lines.

This link does not provide me with anything - could you please just copy and paste your script instead, its much easier