Test Case stops executing once it is switched to WebView

I am writing test cases for the Hybrid application. I am trying to switch to webview in order to perform some actions on webview related elements. But the test case stops executing once it is switched to webview . It throws no error and just stops executing.

I have tried both the ways one using katalon keywords and other using appium method. Nothing works.

Method1: Using Katalon Keyword
AndroidDriver driver = MobileDriverFactory.getDriver()

Mobile.delay(5)

Mobile.switchToWebView(FailureHandling.STOP_ON_FAILURE)

Method2: Using appium
AndroidDriver driver = MobileDriverFactory.getDriver()

Mobile.delay(5)

Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName)
}

driver.context(contextNames.toArray()[1]);

myText = driver.findElement(By.xpath(“//*[@id = ‘front’]/child::div”))

If anyone has already faced this problem, It would be of great help if given a solution.

Thanks,

Sravya