I'm working with Geb on automating testing of a web application that uses ExtJS to present much of its UI. I'm in a situation where I need to ctrl-click several ExtJS-generated table cells representing 'categories'. How do I use Geb to ctrl-click these things?
To do control-clicking I had to access a WebDriver WebElement object directly using firstElement:
def categoryItem = $("div.category-item-title", text: categoryName).firstElement()
Then the Actions object can be used to add control-click actions:
Actions actions = new Actions(driver)
actions = actions.keyDown(Keys.CONTROL)
actions = actions.click(categoryItem)
actions = actions.keyUp(Keys.CONTROL)
actions.perform()
Note this code is within an instance method of a page object.
Here is the same code using the 'interact' mechanism erdi mentioned:
interact {
keyDown(Keys.CONTROL)
click($("div.category-item-title", text: categoryName))
keyUp(Keys.CONTROL)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With