2

With TestNG 7.0.0 and Eclipse 2019-03 When trying to use @Optional Parameters value, it comes with double-quotes. Not getting why?

Check the below screenshot for details.

[enter image description here]

What am I missing? I expect the optional value without quotes just like myBrowser variable.

Muzzamil
  • 2,823
  • 2
  • 11
  • 23
Abhi
  • 53
  • 1
  • 7
  • I have just run into the same problem. I know you posted this almost a year ago, but did you manage to figure out how to solve this annoying issue? As you wrote below, it's possible to avoid the problem my explicitly getting rid of the quotation marks with "replace" (or similar) but that feels like a weird workaround, so I'm wondering if there's a better way? – The Theoretical Astronaut Nov 29 '20 at 22:48

1 Answers1

0

This is correct way to use @optional annotation.

I hope you know it that we can pass values from Testng.xml to @Test. If we are not passing any value from xml to test case then @Optional comes in picture. Whatever value we will pass in @Optional it will be default value. So that we need to pass this value in double quotes as it is not a function arguement.

For more detail, check it:

https://www.seleniumeasy.com/testng-tutorials/optional-annotation-in-testng

Muzzamil
  • 2,823
  • 2
  • 11
  • 23
  • Thanks, @Muzzamil for your comment but still I am not getting this right. If you see the last output block from the link you mentioned, it shows **IamOptional** without any quotes. I am doing the same but I am getting it with double-quotes. If I add code like @Optional(mychrome) then it doesn't get compile. I have to add @Optional("mychrome") then it gets compiled but I am expecting here mychrome in the output without any quotes but it always showing with quotes. I know we can replace quotes from the string for a workaround but the based behavior remains unanswered. – Abhi Dec 23 '19 at 09:53