Robot robot = new Robot()
robot.keyPress(KeyEvent.VK_Ctrl) //This method will press the Ctrl key of the Keyboard
robot.keyPress(KeyEvent.VK_N) //This method will press the N key of the Keyboard
robot.keyRelease(KeyEvent.VK_N) //This method will release N key of the Keyboard
robot.keyRelease(KeyEvent.VK_Ctrl) //This method will release ctrl key of the Keyboard
For giving enter to a text box you have to capture the xpath for the textbox.
to take xpath for a text box you need to know about the following
1.1. right click the textbox or a text in your website and select inspect
1.2. click this icon and click the text box or text or label for which you need xpath.
1.3 Generate Xpath using the below steps
XPath Locators
sample DOM
TagName
1. all in purple is the Tag Name
AttributeName
2. all text in brown is the attribute Name
AttributeValue
3. all text in blue next to brown text = are attribute value
Syntax to build Xpath
//Tag Name[@Attribute Name=“Attribute Value”]
for the above code, you have to generate like this //[@=""]
Now you generated xpath for the required textbox or label or text
after generating this go to the
object repository and right-click–>new test object give a name and the below window appears In the below window enable the xpath radio button
Edit: or //input[@type="text"]
but this one is likely not unique and therefore you will need to add more attributes to make it unique, like. //input[@type="text"][@name="uid"]
or //input[@type="text" and @name="uid"]