I'm trying to switch to web view on katalon but there is an error below

Reason:
com.kms.katalon.core.exception.StepFailedException: Cannot find any WEBVIEW to switch to
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:51)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.stepFailed(MobileKeywordMain.groovy:40)
at com.kms.katalon.core.mobile.keyword.builtin.SwitchToWebViewKeyword$_switchToWebView_closure1.doCall(SwitchToWebViewKeyword.groovy:74)
at com.kms.katalon.core.mobile.keyword.builtin.SwitchToWebViewKeyword$_switchToWebView_closure1.call(SwitchToWebViewKeyword.groovy)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:21)
at com.kms.katalon.core.mobile.keyword.builtin.SwitchToWebViewKeyword.switchToWebView(SwitchToWebViewKeyword.groovy:67)
at com.kms.katalon.core.mobile.keyword.builtin.SwitchToWebViewKeyword.execute(SwitchToWebViewKeyword.groovy:62)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.switchToWebView(MobileBuiltInKeywords.groovy:1953)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$switchToWebView$0.call(Unknown Source)
at
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:448)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1692152963177.run(TempTestCase1692152963177.groovy:25)

2 Likes

@cyntiaverolita Can you make sure that there is a WEBVIEW context available to the driver. This code snippet should print out all the contexts available. I believe the built in keyword will look for a context named “WEBVIEW” but if it is named something different you may need to switch to that context manually. In my case one of the webviews I switch to had a title name appended onto the WEBVIEW string.

AndroidDriver<?> driver = MobileDriverFactory.getDriver();
Set<String> contextNames = driver.getContextHandles();

for (String contextName : contextNames) {
	KeywordUtil.logInfo('contextName = ' + contextName)

If you find that there is a different name for the context that you want to switch to you should be able to by using the command

driver.context(contextName)
1 Like

how to switch this?

Hi All, I still face this issue.

@cyntiaverolita are you able to add the lines from the above comment to the test where you want to switch to the webview context? It should print out contexts that are available so we can see if you need to manually switch to a different context for this to work correctly.