When interacting with different elements and applying multiple actions it may be quite convenient in some situations if we could do:
WebElement myInput = driver.findElement(By.id("my-input-id"));
myInput.clear().sendKeys("test");
Instead of:
WebElement myInput = driver.findElement(By.id("my-input-id"));
myInput.clear()
myInput.sendKeys("test");
But, the problem is clear()
, sendKeys()
and other "action" methods cannot be chained as is - they return void
and not the current WebElement
.
What would be the easiest way to achieve chaining multiple actions?