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:
xxxxxxxxxx
1
2
class ProductsPage extends Page {
3
4
static url = '/shop/products'
5
6
static content = {
7
// ...
8
cancelButton() { $('button', text: contains('Cancel')) }
9
// ...
10
}
11
}
ProductsTest.groovy
file:
xxxxxxxxxx
1
// ...
2
3
class ProductsTest extends BaseUITest {
4
5
// ...
6
7
def 'Check loaded product in edit mode' () {
8
setup:
9
ProductsPage page = to ProductsPage
10
11
when:
12
13
// click to edit product button here ...
14
15
conditions.eventually {
16
assert page.cancelButton.isDisplayed() // if true it means edit mode is displayed
17
}
18
19
// some actions that changes product ...
20
// click to save product bunnon here ...
21
22
conditions.eventually {
23
// the problem is here !!!
24
//
25
// when I run:
26
// !$('button', text: contains('Cancel')).isDisplayed()
27
// everythink works fine.
28
//
29
// when I run:
30
assert !page.cancelButton.isDisplayed() // if true it means edit mode is closed
31
// I get timeout exception.
32
}
33
34
then:
35
asset productId == null
36
}
37
}
38
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
xxxxxxxxxx
1
cancelButton(required: false, cache: false, wait: 30) {
2
$('button', text: contains('Cancel'))
3
}
0 commentsShow commentsAdd comment