Refactored that to handle federated pages much better, so that it will handle redirect. Before sending key events, it needs sleep to simulate key press. Otherwise, it fails sometimes if field did not have focus yet or similar.