Reputation:
Inputting a text then pressing the enter key on a single line or using a single statement if possible .
tried separating the input of text and the pressing of the enter key
tried this but is it possible to make it just one statement?
WebElement department = driver.findElement(By.xpath("//input[@class='txtdepartment txtenter_event']"));
WebElement department1 = driver.findElement(By.xpath("//input[@class='txtdepartment txtenter_event']"));
department.sendKeys("10");
department1.sendKeys(Keys.CONTROL,"a");
Code
WebElement department = driver.findElement(By.xpath("//input[@class='txtdepartment txtenter_event']"));
department.sendKeys(Keys.chord(Keys.CONTROL, "a"), "10");
I want to input the 10 first before the keys.control or pressing enter key
Upvotes: 0
Views: 465
Reputation: 345
sendKeys
method accepts variable number of arguments of type CharSequence
You can use
department.sendKeys("10", Keys.ENTER)
Or
department.sendKeys("10", Keys.RETURN)
Selenium will send the key sequence as first argument, followed by second and so on...
Upvotes: 1
Reputation: 64
You can just send them one by one. (I changed it to python code :) )
department = driver.find_element_by_xpath("//input[@class='txtdepartment txtenter_event']")
department.sendKeys("10")
department.sendKeys(Keys.CONTROL)
Upvotes: 0