I'm trying to write a simple Java based selenium code where I would load a page, give the desired values to username & password and login to web page.
Now once the web page loads it automatically waits for user to enter username i.e username is already focused. So can I send the keys to this already focused element. Once I have given the input to username I could use TAB to select the next input i.e. password and then TAB again to select the Login button.
Try this - WebElement currentElement = driver.switchTo().activeElement();
Refer to this for more details - https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.TargetLocator.html#activeElement--