1

I am sending request in multiple language(say en,de) and I have stored res of all href link present in body.I want to validate if href in response has valid language code or not. href appears in response has language code as http(s)://abc.com/**en**/def.html or http(s)://lmn.com/**en_US**/def.html

//code example 
expectedUrl[1]=http(s)://abc.com/en/def.html
expectedUrl[2]=http(s)://abc.com/de/def.html
expectedUrl[3]=http(s)://abc.com/en_US/def.html
expectedUrl[2]=http(s)://abc.com/de_DE/def.html



pm.test(expectedUrl + ': check url is localised', function () {
  pm.expect(err).to.equal(null);//works fine
  pm.expect(res).to.have.property('code', 200);//works fine 
  pm.expect(res).to.have.property('status', 'OK');//works fine 
  pm.expect([expectedUrl[i]]).include({{lang}}); //How can i achieve this validation 
});

Hakan Dilek
  • 2,178
  • 2
  • 23
  • 35
Chandan
  • 11
  • 2
  • currently how i am trying is: var resurl=['http(s)://abc.com/en/def.html','http(s)://abc.com/de/def.html','http(s)://abc.com/en_US/def.html','http(s)://abc.com/de_DE/def.html','xxxxxxxxx','yyyyyyyyyyy'] pm.test(expectedUrl + ': check url is localised', function () { pm.expect((res.links[keyName])[i].href).to.be.oneOf(resurl); //How can i achieve this validation }); problem here is I have multiple res url to keep in array and it changes everytime. looking for better solution – Chandan May 25 '20 at 12:13
  • I am able to solve this problem now . We can close this – Chandan May 29 '20 at 13:16

0 Answers0