Hi,
I would really appreciate some help on this one?
I have managed to get a cookie name from the browser, store it on a variable and then apply a verifymatch to a predefined string so then I can check that the cookies are there.
Example:
To the test cases I added these:
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.WebDriver as WebDriver
and wrote the following example where affinitty is a cookie name:
arraffinity = driver.manage().getCookieNamed(‘ARRAffinity’).getName()
WebUI.verifyMatch(‘ARRAffinity’, arraffinity, false)
This is working fine.
But now I would like to verify that certain cookies are “not” there. This is because of GDRP rules that certain cookies should not be there until we click on a accept button.
So for example, I would like to check that at this point there is “no” facebook cookie, cookie called “_fbp”
If I apply this get statement to above to a none exiting cookie
_fbp = driver.manage().getCookieNamed(’_fbp’).getName()
it will give an error message and fails. It will not save a en empty value to the variable:
_fbp = getCookieNamed("_fbp").getName() FAILED.
Reason:
java.lang.NullPointerException: Cannot invoke method getName() on null object
- at Functional and Marketing cookies.run(Functional and Marketing cookies:32)*
- at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)*
- at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)*
- at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)*
- at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)*
- at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)*
- at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)*
- at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)*
- at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)*
- at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)*
- at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)*
- at TempTestCase1590144699572.run(TempTestCase1590144699572.groovy:22)*
So I thought of getting maybe all list of cookies present, store them into a variable and then apply the verifytext not present
all_cookies = driver.manage().getCookies()
WebUI.verifyTextNotPresent(’_fbp’, all_cookies, FailureHandling.OPTIONAL)
But I get again this error message:
VerifyTextNotPresent("_fbp", all_cookies, OPTIONAL) FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextNotPresent() is applicable for argument types: (java.lang.String, java.util.HashSet, com.kms.katalon.core.model.FailureHandling) values: [_fbp, [ASP.NET_SessionId=zmoawq20oeblv3rdy3pud4lo; path=/; domain=pre.yara.com, …], …]
Possible solutions: verifyTextNotPresent(java.lang.String, boolean, com.kms.katalon.core.model.FailureHandling), verifyTextNotPresent(java.lang.String, boolean), verifyTextPresent(java.lang.String, boolean, com.kms.katalon.core.model.FailureHandling), verifyAlertNotPresent(int, com.kms.katalon.core.model.FailureHandling), verifyTextPresent(java.lang.String, boolean)
- at Functional and Marketing cookies.run(Functional and Marketing cookies:44)*
- at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)*
- at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)*
- at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)*
- at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)*
- at*
Any ideas on how to check that the specifc cookie name is “NOT” in the cookies in the browser?
Thank you in advance!