?? Do not ever copy/paste to your code from Browser

?? Do not ever copy/paste to your code from Browser

?? On my latest tasks regarding Testing , I had to write some API tests and I made a copy that is remarkable for writing this post.

We are trying to write some tests for an API that has an OpenAPI swagger page with the endpoints and input/output specs like the following :

Swagger Page

? Seems familiar? I felt the same so I tried to copy and paste from this Web Page the endpoint that I want to write the tests.

First attempt to run the test and I got a 404 Not Found exception.

Path not found Exception

?? Ok lets calm down and see what's going wrong.

  1. Do I save correctly the object I want to get? - Yes
  2. Does the same API call works properly from the swagger page? - Yes
  3. Do I miss any params from request ? - No
  4. Do I have any typo on the url of the endpoint? - No
  5. In debug mode : Does the API test call reach to the controller's break point? - NO

So what is wrong with this endpoint? After spent some hours and pair debugging with Thanasis Nikolaidis found the difference on git!

git difference

?? And I was like...

wait what?

The true difference come up with an old-school tool called Notepad++ that shows ALL the characters. Even this ZWSP character!

True difference

After googling the ZWSP character found this : https://en.wikipedia.org/wiki/Zero-width_space


From Wikipedia, the free encyclopedia


Purpose

The zero-width space marks a potential line break without hyphenation; for hyphenated line breaks, a soft hyphen is used. The zero-width space can be used to mark word breaks in languages without visible space between words, such as Thai, Myanmar, Khmer, and Japanese.[1][2]

Unlike fixed-width spaces, in justified text that increases spacing between letters, characters adjacent to the zero-width space are spaced as if it was not present.[2]


?? After I laughed with tears, I fixed the issue and learned that I will never, ever again copy urls from a web page if I want to use them in my code.


Happy testing

Samuel Nitsche

Quality Engineering Consultant, Keynote-Speaker ??, curiosity-driven and test-obsessed Software-Developer, Software-Anthropologist, Oracle ACE Alumn??, Workshop-Facilitator, Knowledge-Spreader

1 年

Once you know this kind of thing (zero-width characters) exist, it is easy to configure your preferred IDE to show them. Therefore I don't follow your conclusion about "never copy a URL" - the problem was not that you copy pasted, but that you had a knowledge gap (which is totally normal). The conclusion reminds me of "never use pointers" or "never use dynamic SQL" - I would rather rephrase it as "When copying URLs, remember there are things like zero-width characters". But I guess that's not as catchy ;)

John Pourdanis

???? Professional Nothing Knower | Quality Engineering in Software Industry

1 年

I also found how to show those kind of characters to Visual Studio and to VS code. I think most of IDEs will have the option.

  • 该图片无替代文字
回复
Charalampos Iliadis

Test Automation Engineer Team Lead??Workview COG

1 年

I've spent hours in the past troubleshooting an sql query that contained a Greek character...

Millan Kaul

Quality Engineering Leader | Result focused Data driven ? Delivering high Quality products with speed & style ?? Meetup, conference keynote Speaker ?? #QualityWithMillan

1 年

ZWSP, nice one ??

Anastasios Tilsizoglou

Just another Software Engineer | MSc in Computer Science

1 年

You can turn this article to a nice thriller mini movie! I was even terrified only reading this. How many hours it took you just to find this and how many times you thought about to throw the computer from the window? ??

要查看或添加评论,请登录

John Pourdanis的更多文章

  • Web Camera testing with Cypress

    Web Camera testing with Cypress

    THE PROBLEM When you want to automate clicks and inputs things are straight forward in the test automation world…

    2 条评论
  • Javascript testing can drive you crazy

    Javascript testing can drive you crazy

    Imagine that you have a frontend application that has a data table and you want to validate that is not empty. So you…

    5 条评论
  • "Alexa do a staging deploy"- Automate everything

    "Alexa do a staging deploy"- Automate everything

    This is my first article here in LinkedIn so excuse me for any errors, faults or issues. If you are a truly automation…

    9 条评论

社区洞察

其他会员也浏览了