What is the difference between type keys and type commands?

How can we type keys and type commands through selenium automation

2 Likes

typekeys() will trigger event in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing

Here You can Type ShortCut Keys to Interact with Browsers e.g CTRL + T (New Tab) and When you want to type command you can use Javascript Execution flow

E.g.

Type Keys:

driver.sendKeys(Keys.CONTROL + "t");

Type Command:

driver.ExecuteScript("window.open('your URL', '_blank');");
1 Like