Storing text of page source code as a string

Does anyone know how to store the source code of your page as a string? I tried sending the keys “Ctrl+U” and then trying to assert whether an element is present on the source code is present. Anyone know any workarounds to this?

You can use getSourceCode() function to get it. Below is a sample how to get a full source code :

import org.openqa.selenium.WebDriver
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.openBrowser('google.com')

WebDriver driver = DriverFactory.getWebDriver()

'Get source code of current page'
driver.getPageSource()

WebUI.closeBrowser()

driver.getPageSource()

Source code is saved to which location ?