EN
Geb doesn't see element handle change in my tests in Groovy
1
answers
4
points
I have some problem with my e2e tests. I use Groovy with Geb as Selenium wrapper.
When I call cancelButton()
twice as second result I get same element - even state changed.
I have 2 files.
ProductsPage.groovy
file:
@Slf4j
class ProductsPage extends Page {
static url = '/shop/products'
static content = {
// ...
cancelButton() { $('button', text: contains('Cancel')) }
// ...
}
}
ProductsTest.groovy
file:
// ...
@Slf4j
class ProductsTest extends BaseUITest {
// ...
def 'Check loaded product in edit mode' () {
setup:
ProductsPage page = to ProductsPage
when:
// click to edit product button here ...
conditions.eventually {
assert page.cancelButton.isDisplayed() // if true it means edit mode is displayed
}
// some actions that changes product ...
// click to save product bunnon here ...
conditions.eventually {
// the problem is here !!!
//
// when I run:
// !$('button', text: contains('Cancel')).isDisplayed()
// everythink works fine.
//
// when I run:
assert !page.cancelButton.isDisplayed() // if true it means edit mode is closed
// I get timeout exception.
}
then:
asset productId == null
}
}
Is it possible that Geb caches handles in content
block?
1 answer
2
points
Yes, according to your question: Geb caches references to elements in content
block.
Try to use cache: false
cancelButton(required: false, cache: false, wait: 30) {
$('button', text: contains('Cancel'))
}
0 comments
Add comment