-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String parameter beginning with numbers are wrongly interpreted as numbers #190
Comments
Re-opening to cover the following case #191 (comment) |
We also need to be careful with a simple |
I believe this is covered in the current code. I've tried the following.
Have you tried running it? |
In 0.3.5 I'm getting "1" passed down as a number instead of string. This is my step.
And this is my step implementation: @Step("Write <value> into <name>")
public static async writeInto(value: string, name: string) { /*...*/ } To clarify: this step is a part of test that will check that the field shows "invalid phone number" warning. Is it possible to get the correct type from the implementation method definition instead of blindly trying to convert to number if it fits? |
Just my $0.02: Upgrading from gauge 0.1 -> 0.3, I was quite surprised by the whole "automatic primitive type parsing", since previously it was all a string. IMO these odd edge cases are a good reason to go back to the default of just assuming everything is a string. As I write step implementations, I can have custom logic since I know what format I expect the string to be in, and parse it if required for that step. (For some context: I had a lot of steps which accepted "numeric" arguments, but were used as strings, and now it was all failing). |
Sorry to comment out of the blue. I use Playwright with Gauge, and the steps I have implemented are as follows: @Step("fill <value> to the input element")
public async fillInput(value: string) {
const locator = getCurrentLocator();
await locator.fill(value);
} This step is used like this: * In the e-mail address input field:
* fill "[email protected]" to the input element
* In the phone number input field:
* fill "0123456789" to the input element Method Because of this automatic conversion, I still have not been able to update my version from 0.1.1 to 0.3.x. |
In retrospect, the decision to convert based on the parameter is not ideal. The ideal approach instead is to determine the step parameter’s type and attempt a conversion to the target type. However, type information is unavailable at runtime when the step is loaded. I’ll investigate further, but for now, I agree about reverting to the original behaviour of assuming everything to be a string. |
Describe the bug
Say we have spec like this one:
* Get product with id "81423165-ad04-4c7b-9f85-75d1a8aa1b0d"
Since #186, which now uses
Number.parseFloat
directly instead ofNumber
constructor in thePrimitiveParser
, strings like the UUID above or even parameters which could be product IDs like "012345" are now successfully converted to Number (instead ofNaN
), dropping useful characters in the process (excess hex letters for the UUID, leading zeroes for the product ID)...which makes it pretty much unusable right now.To Reproduce
Steps to reproduce the behavior:
Just use a UUID or a static parameter beginning with one or more 0
Expected behavior
A clear and concise description of what you expected to happen.
With a spec like:
* Get product with id "81423165-ad04-4c7b-9f85-75d1a8aa1b0d"
and an implementation like:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: