首页 > 解决方案 > 空手道 UI 自动化 - 断言失败,消息“实际值不像 JSON”,用于 driver.title 比较

问题描述

我正在尝试将空手道用于 UI 自动化,但我遇到了一个基本场景,我试图验证页面标题

以下是我的场景步骤:

 Scenario: Validate page title
    Given driver 'https://google.com'
    And driver.maximize()
    Then match driver.title == 'Google'

当我运行它时,我收到以下错误:

assertion failed: path: $.title, actual: 'Google', expected: ''Google'', reason: actual value is not JSON-like abc.feature:16 - path: $.title, actual: 'Google', expected: ''Google'', reason: actual value is not JSON-like

如果我使用:

Then match driver.title == Google

我得到以下错误:

javascript evaluation failed: driver.title, null

额外细节:

karate-junit4 = 9.4.0
* configure driver = { type: 'chrome', showDriverLog: false }

正如评论中所建议的,也使用了 0.9.5.RC3。收到此错误:

assertion failed: path: $, actual: '', expected: 'Google', reason: not equal

谁能指出我在这里遗漏了什么?

标签: ui-automationkarate

解决方案


最后更新:这个问题是 0.9.4 的一个错误。请从以下链接查看详细说明:问题链接:https ://github.com/intuit/karate/issues/913


推荐阅读