简体   繁体   中英

API testing using Selenium and Java

I am new to programming and testing API's and have done all the basics of selenium for browser calls. After running my browser functionalities with selenium, I have to invoke an API to complete a remaining functionality. The developer has provided an API to me with JSON input format. Can I do it in Selenium? and if yes, how can I do it?

for eg, I am performing a transaction on an Ecommerce website using selenium. Now to invoke the refund for this transaction I have been provided an API where I will have to enter the Transaction ID of the transaction done earlier in JSON format.

Pls help

It's not about Selenium. You should set-up your environment so that the frontend communicates with a mock backend. As one possible approach you can start a mock backend on the same URL as on the real backend would be.

There are other possible solutions which involve replacing the real endpoint URL or communication channel on the HTML/JS with a test-URL during testing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM