filmov
tv
Selenium with Java 34 - Actions class sendkeys for removing the existing text method
![preview_player](https://i.ytimg.com/vi/UcPs5gERgUQ/maxresdefault.jpg)
Показать описание
Actions class sendkeys for removing the existing text method.
How to Clear text box content by using actions Sendkeys?
actions class sendKeys method:
sendKeys(CharSequence key)- Sends a sequence of keystrokes to the browser.
sendKeys(WebElement target, CharSequence key)- Sends a sequence of keystrokes to the specified element in the browser.
actions class keyDown method :
keyDown(CharSequence key)- Sends a modifier key down message to the browser.
keyDown(WebElement element, CharSequence Key)-
Sends a modifier key down message to the specified element in the browser.
actions class keyUp method :
keyUp(CharSequence key) -Sends a modifier key up message to the browser.
keyUp(WebElement element, CharSequence key)- Sends a modifier up down message to the specified element in the browser.
Possible Interview Questions on selenium sendkeys, keyup and keydown :
How to Clear text box content by using actions sendKeys ?
What is the differences between webelement sendkeys and actions sendkeys?
Code :
@Test
public void fillFormUsingSendkeys() throws InterruptedException
{
WebDriver driver = new FirefoxDriver();
Actions actions = new Actions(driver);
actions
.sendKeys("password1234" + Keys.TAB)
.sendKeys("password1234" + Keys.TAB)
.build()
.perform();
}
How to Clear text box content by using actions Sendkeys?
actions class sendKeys method:
sendKeys(CharSequence key)- Sends a sequence of keystrokes to the browser.
sendKeys(WebElement target, CharSequence key)- Sends a sequence of keystrokes to the specified element in the browser.
actions class keyDown method :
keyDown(CharSequence key)- Sends a modifier key down message to the browser.
keyDown(WebElement element, CharSequence Key)-
Sends a modifier key down message to the specified element in the browser.
actions class keyUp method :
keyUp(CharSequence key) -Sends a modifier key up message to the browser.
keyUp(WebElement element, CharSequence key)- Sends a modifier up down message to the specified element in the browser.
Possible Interview Questions on selenium sendkeys, keyup and keydown :
How to Clear text box content by using actions sendKeys ?
What is the differences between webelement sendkeys and actions sendkeys?
Code :
@Test
public void fillFormUsingSendkeys() throws InterruptedException
{
WebDriver driver = new FirefoxDriver();
Actions actions = new Actions(driver);
actions
.sendKeys("password1234" + Keys.TAB)
.sendKeys("password1234" + Keys.TAB)
.build()
.perform();
}