filmov
tv
Selenium with Java 33 - Fill entire form in a single statement using Actions sendkeys

Показать описание
How to fill entire form in a single statement using Actions sendKeys
sendKeys in selenium actions class :
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.
Possible Interview Questions on selenium actions class sendkeys method:
How to Fill entire form in a single statement using 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();
}
sendKeys in selenium actions class :
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.
Possible Interview Questions on selenium actions class sendkeys method:
How to Fill entire form in a single statement using 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();
}