简体   繁体   中英

How to handle the basic authentication (Rest API- Post Request) with selenium webdriver code?

如何使用selnium Webdriver和Java处理Rest-API的基本身份验证

Actually you have more than one solution:

1- You can use user:password@yourURL.com (Make sure that username or password doesn't contain any special characters).

2- You can add a header key "Authorization" to your request with credEncodedString as a value for that key: byte[] credentials = (userName + ":" + password).getBytes(); String credEncodedString = "Basic " + Base64Encoder.encode(credentials);

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