首页 文章

使用空手道和硒webdriver的能力

提问于
浏览
1

我在一周前开始使用空手道,这是我的第一个问题 . 我曾经使用Spock&groovy,放心和黄瓜来编写Web服务测试 . 当我遇到空手道时,我觉得这很有趣 . 谢谢你的巨大努力 .

我发现空手道确实能够满足我对自动化Json服务的需求 . 但是,我想了解更多细节 . 我使用另一个框架以及groovy,Spock和Java . 在我的场景中,我需要发送一个json请求,从响应中获取事务ID,然后使用selenium web驱动程序执行UI测试 . 如何轻松地将空手道测试与硒网络驱动程序集成?这是一个示例场景,包括spock中的Web服务和UI

given: "Submit  Request and get valid response"
    getResponse("request.template", "/mypersonal")
    assert respStatus == 200
    String myOrderID = getValueFromResponse(orderId)
    verifyMyOrder(myOrderID)

    when: "Start the browser for executing the functionality and Navigate to app"
    WebDriver driver = DriverFactory.getInstance().getWebDriver()
    ObjectFactory oFctry = new ObjectFactory(driver)
    driver.navigate().to(url)
    oFctry.uLogin()
    oFctry.navigateToPersonalFile()

    then: "Validate the File"
    oFctry.searchInInDirectory(myOrderID)
    oFctry.navigateToProductDetailsPage(myOrderID)

    cleanup: "Close the chrome browser"
    DriverFactory.getInstance().removeDriver()

1 回答

  • 1

    您有2个选项,从Karate调用Selenium驱动程序或通过Java API调用Karate .

    • 使用Java库将Java代码混合到空手道测试(本例中为JDBC)的示例:dogs.feature . 另请参阅文档中的如何call Java .

    • 如何从Java调用空手道的文档:Java API

    就个人而言,我更喜欢选项1 - 这是你一直在用Spock做的 .

相关问题