空手道与硒webdriver一起使用的能力 [英] Capability of using Karate along with selenium webdriver
问题描述
一周前,我开始使用空手道,这是我的第一个问题.我曾经使用Spock&时髦,放心&黄瓜.当我遇到空手道时,我觉得这真的很有趣.感谢您的辛勤工作.
I started using Karate one week back and this is my first question. I used to write web service tests using Spock & groovy, Rest assured & cucumber. When I came across Karate I felt it's really interesting. Thank you for your huge effort.
我发现空手道确实有能力并且满足我对自动化Json服务的需求.但是,我想知道更多有关此的细节.我与groovy,Spock和Java一起使用了另一个框架.在我的场景中,我需要发送一个json请求,从响应中获取事务ID,然后使用Selenium Web驱动程序执行UI测试.如何轻松将空手道测试与Selenium Web驱动程序集成?这是一个示例场景,包括Web服务和Spock中的UI
I found Karate really capable and satisfying my needs to automated Json services. However, I would like to know some more details on this. I use another framework along with groovy, Spock and Java. In my scenario, I need to send a json request, get the transaction id from the response and then execute the UI test using selenium web driver. How can I easily integrate Karate tests with selenium web driver? This is a sample scenario including web service and UI in spock
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()
推荐答案
您有2种选择,可以从Karate调用Selenium驱动程序,也可以通过Java API调用Karate.
You have 2 options, call Selenium driver from Karate or call Karate via the Java API.
- Example of mixing Java code using a Java library into a Karate test (JDBC in this case): dogs.feature. Also refer to how to call Java in the documentation.
- Documentation for how to call Karate from Java: Java API
我个人更喜欢选项1-这是您使用Spock所做的.
Personally, I prefer option 1 - which is what you have been doing with Spock.
空手道现在支持Web浏览器自动化,因此您不再需要Selenium:
Karate now supports Web Browser automation, so you don't need Selenium anymore: The world needs an alternative to Selenium - so we built one
这篇关于空手道与硒webdriver一起使用的能力的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!