I have some methods in a module (groovy Spock framework. The methods all shared a common pattern. I want to make a method for this common pattern, then call on it from the mentioned methods.
two of the methods which shared the same pattern are: (I show just two of them here but they are more).
```
void setPayloadIndexRetention(String payloadIndexRetention) {
if (payloadIndexRetention==null){
payloadIndexRetention='30 days(default)'
}
arielRetention.find('input', class: contains('dijitArrowButtonInner')).click()
arielRetentionmenu.find('td', text: payloadIndexRetention).click()
sleep(5000)
}
```
`arielRetention` and `payloadIndexRetention` are defined in the module content as:
```
arielRetention { $('table', id: 'ARIEL_FREE_TEXT_RETENTION') }
arielRetentionmenu { $('table', id: 'ARIEL_FREE_TEXT_RETENTION_menu') }
```
``` void setPrivacyProtocol(String privacyProtocol) {
if (privacyProtocol==null){
privacyProtocol='DES'
}
snmpPrivacyProtocol.find('input', class: contains('dijitArrowButtonInner')).click()
snmpPrivacyProtocolmenu.find('td', text: privacyProtocol).click()
sleep(5000)
}
```
`snmpPrivacyProtocol` and `snmpPrivacyProtocolmenu` are:
```
snmpPrivacyProtocol { $('table', id: 'SNMP_V3_DEC_PROTO') }
snmpPrivacyProtocolmenu { $('table', id: 'SNMP_V3_DEC_PROTO_menu') }
```
I made another method that includes the shared pattern:
```
void setParameter (String parameter, String defaultValue, def navigator1, def navigator2){
if (parameter==null){
parameter=defaultValue
}
navigator1.find('input', class: contains('dijitArrowButtonInner')).click()
navigator2.find('td', text: parameter).click()
}
```
When I call `setParameter` on the `setPayloadIndexRetention` method, and run my test I get the following error:
```
geb.error.RequiredPageContentNotPresent: The required page content 'geb.qradar.gebpages.SystemSettingsPage -> settings: geb.qradar.gebmodules.SystemSettingsModule -> arielRetentionmenu: geb.navigator.DefaultNavigator' is not present
```
Does anyone have any idea where am I making a mistake?
I also use `Navigator` instead of `def as parameter type, the issue was still there.
What I have tried:
I tried what I mentioned in the above post.