【发布时间】:2019-01-01 12:46:12
【问题描述】:
刚开始使用 Katalon Recorder。导航和加载页面后,有没有办法存储整个页面文本?我正在尝试自动化一个功能,我必须单击列表项,全选,复制并粘贴到 excel 中。
【问题讨论】:
-
“页面文字”是什么意思?您可以使用
driver.getPageSource()获取页面源。这就是你想要的吗?
标签: katalon-studio katalon-recorder
刚开始使用 Katalon Recorder。导航和加载页面后,有没有办法存储整个页面文本?我正在尝试自动化一个功能,我必须单击列表项,全选,复制并粘贴到 excel 中。
【问题讨论】:
driver.getPageSource() 获取页面源。这就是你想要的吗?
标签: katalon-studio katalon-recorder
Mate Mrše 的评论开了个好头。这是一些充实细节的示例代码。以下代码将页面保存到 html 文件。从那里您需要进行额外的处理才能将其转换为另一种文档格式,例如 Excel。
// add the following two imports for the webdriver
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.WebDriver as WebDriver
// open browser/navigate, etc
// WebUI.openBrowser('https://google.com')
WebUI.delay(5)
WebDriver driver = DriverFactory.getWebDriver()
def src = driver.getPageSource()
def file1 = new File('c:/1/the_saved_web_page.htm')
file1.write(src)
【讨论】: