best to use frameToBeAvailableAndSwitchToIt expected condition: https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#frameToBeAvailableAndSwitchToIt(int) This will wait until the frame has loaded.