verifyTextPresent not working on CRM

Hello everyone,

I’ve been trying to make the method work on CRM, but it doesn’t seem to be able to locate the text. Basically what I’ve been trying to do is to see if the record I’ve created from the Portal side of my website is also created in CRM Dynamics. Then once it’s been found, click on that element.

Here, it shows that the name of the record is saved in my variable:

Here, it shows that my record is created in CRM:

The error i got is this:

02-25-2019 12:49:01 PM Test Cases/CRM PMT6

Elapsed time: 1m - 24,535s

Test Cases/CRM PMT6 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify text 'LDT EXP 25/02/2019 12:49' is present  using regular expression (Root cause: com.kms.katalon.core.exception.StepFailedException: Text 'LDT EXP 25/02/2019 12:49' is not present on page  using regular expression)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.verifyTextPresent(VerifyTextPresentKeyword.groovy:83)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.execute(VerifyTextPresentKeyword.groovy:68)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextPresent(WebUiBuiltInKeywords.groovy:1693)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextPresent$8.call(Unknown Source)
	at CRM PMT6.run(CRM PMT6:42)
	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 TempTestCase1551116938175.run(TempTestCase1551116938175.groovy:22)

My code:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

WebUI.callTestCase(findTestCase('Potato Export WIP - Copy'), [:], FailureHandling.STOP_ON_FAILURE)

//WebUI.openBrowser('')

WebUI.navigateToUrl('https://sts-sejs.dev.global.gc.ca/adfs/ls/?wa=wsignin1.0&wtrealm=https%3a%2f%2fesdp-test-cfia-acia-cdt.dev.global.gc.ca%2f&wctx=rm%3d1%26id%3d1c43765b-2449-446f-9093-f4ee73a7c593%26ru%3dhttps%253a%252f%252fesdp-test-cfia-acia-cdt.dev.global.gc.ca%252fmain.aspx%26crmorgid%3d8814f2eb-2d3e-e611-80ef-005056817939&wct=2019-02-19T16%3a34%3a50Z&wauth=urn%3aoasis%3anames%3atc%3aSAML%3a1.0%3aam%3apassword#364847500')

WebUI.setText(findTestObject('Object Repository/CRM PMT6/input_JavaScript requis_UserNa'), 'yoyo@why.ca')

WebUI.setEncryptedText(findTestObject('Object Repository/CRM PMT6/input_JavaScript requis_Passwo'), 'q7GPlJJ7WwlAGos1HEj2aT8r9TL5JOQZ')

WebUI.click(findTestObject('Object Repository/CRM PMT6/span_Connexion'))

WebUI.click(findTestObject('Object Repository/CRM PMT6/input_concat(Take a quick tour (1)'))

WebUI.click(findTestObject('CRM PMT6/a_Microsoft Dynamics CRM_butto'))

WebUI.mouseOver(findTestObject('CRM PMT6/a_Microsoft Dynamics CRM'))

WebUI.delay(1)

WebUI.click(findTestObject('CRM PMT6/a_Export'))

WebUI.mouseOver(findTestObject('CRM PMT6/span_Export'), FailureHandling.STOP_ON_FAILURE)

WebUI.delay(1);

WebUI.click(findTestObject('CRM PMT6/a_Cases'))

System.out.println(GlobalVariable.case_ID);

WebUI.verifyTextPresent(GlobalVariable.case_ID, true)

So I call the first Test Case and save a string value onto my Global Variable called “case_ID” and then use that variable to check if the text exists on CRM.

Can anyone help me figure out a workaround?

GlobalVariables are unfortunately tricky (they shouldn’t be, but they are). So rather than opening that can of worms, how about you try something like the following.

Test Cases can return a value (your Test Case is actually a method running in a Groovy script class). And since you’re calling the TC like it’s a method, why not treat it as one?

So in the first TC, just…

...
return case_ID

Then, in your calling TC…

def case_ID = WebUI.callTestCase(findTestCase('Potato Export WIP - Copy'), ...)
System.out.println(case_ID)
...

Your method works as well, it stores the value into the variable. However, the verifyTextPresent method cannot find the stored value on CRM. I’ve tried the method on my portal side and it can find any String that I pass to it.

Any advice?

Strange.

Some guesses…

Does it need to be a regex? Is the value a valid regex?

Is the text actually present when the test step is executing? (Did you try waiting?)

It doesn’t need to be a regex, actually it has to be a String. I made sure that the return value is a String. I’ve tried using the verifyTextPresent on the CRM page just to see if it could detect it when the Text was on the page, but it could not detect it.

:confused:

There’s no issue with verifyTextPresent - pretty sure of that (we’d see a ton of complaints if there were). So there must be some reason why the text is evading the driver on the CRM site.

Dumb question: Is it actually present as text… i.e. “free text” in a span or similar? It’s not inside an input field of some description?

Using the WebSpy tool, it gives this:

image

Many records are created daily because other people are also testing different functionalities. The text can be clicked and leads to another page within CRM in order to do manipulation.

I also think that verifyTextPresent works fine since I tried using it on other web pages and it is capable of detecting the texts. It seems that it doesn’t work on CRM.

Any help would be appreciated.

So it’s in a frame… did you configure the test object to use a frame?

I don’t use Katalon like this, so I’m winging this from the dark side of the moon. :wink:

1 Like

You might on to something. Will do some research and get back with the results.

If this is an iframe issue maybe this post would help you:
It might be that you need to switch or use the iframe to access the TestObject.