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

Can't use {0} without quotes in dynamic selector #93

Closed
CamiloCode opened this Issue Aug 30, 2017 · 4 comments

Comments

2 participants
@CamiloCode

CamiloCode commented Aug 30, 2017

I need to pass the just the number value without the quotes but its forcing to do it, otherwise I get an invalid selector issue


static validationIDTypeCedula = Target.the('validation id type cedula')
        .located(by.xpath('//p-dropdown[@id='registry_validation_dropdown_idType']//li[{0}]'));
@jan-molak

This comment has been minimized.

Show comment
Hide comment
@jan-molak

jan-molak Aug 31, 2017

Owner

Thanks @CamiloCode. I'm not sure what number value you're referring to. Could you please give me a bit more context? What is the exact output you're looking for and what are you seeing instead?

Owner

jan-molak commented Aug 31, 2017

Thanks @CamiloCode. I'm not sure what number value you're referring to. Could you please give me a bit more context? What is the exact output you're looking for and what are you seeing instead?

@CamiloCode

This comment has been minimized.

Show comment
Hide comment
@CamiloCode

CamiloCode Aug 31, 2017

yes, sure.

so lets say I want to use the dynamic selector defined above. so if I called it this way. being id_type a number, it will fail , saying its an invalid selector

ValidationForm.validationIDTypeCedula.of(this.id_type)

but if I change the code above to be:

static validationIDTypeCedula = Target.the('validation id type cedula')
        .located(by.xpath('//p-dropdown[@id='registry_validation_dropdown_idType']//li["{0}"]'));

it will work. but I need to create the selector without quotes as I want to get li[1] or li[2]

if I do use the quotes , the selector will be built as li["1"] or li["2"]

CamiloCode commented Aug 31, 2017

yes, sure.

so lets say I want to use the dynamic selector defined above. so if I called it this way. being id_type a number, it will fail , saying its an invalid selector

ValidationForm.validationIDTypeCedula.of(this.id_type)

but if I change the code above to be:

static validationIDTypeCedula = Target.the('validation id type cedula')
        .located(by.xpath('//p-dropdown[@id='registry_validation_dropdown_idType']//li["{0}"]'));

it will work. but I need to create the selector without quotes as I want to get li[1] or li[2]

if I do use the quotes , the selector will be built as li["1"] or li["2"]

@jan-molak

This comment has been minimized.

Show comment
Hide comment
@jan-molak

jan-molak Sep 25, 2017

Owner

OK, I see what you mean. of requires a string argument rather than a number, so to accomplish what you're after you'd need to convert the number to a string:

ValidationForm.validationIDTypeCedula.of(`${this.id_type}`)

then your dynamic selector can remain as is:

static validationIDTypeCedula = Target.the('validation id type cedula')
        .located(by.xpath(`//p-dropdown[@id='registry_validation_dropdown_idType']//li[{0}]`));

Having said that, there's no good reason why of should not accept both strings and numbers. I'll change that in the next version of Serenity/JS

Owner

jan-molak commented Sep 25, 2017

OK, I see what you mean. of requires a string argument rather than a number, so to accomplish what you're after you'd need to convert the number to a string:

ValidationForm.validationIDTypeCedula.of(`${this.id_type}`)

then your dynamic selector can remain as is:

static validationIDTypeCedula = Target.the('validation id type cedula')
        .located(by.xpath(`//p-dropdown[@id='registry_validation_dropdown_idType']//li[{0}]`));

Having said that, there's no good reason why of should not accept both strings and numbers. I'll change that in the next version of Serenity/JS

@CamiloCode

This comment has been minimized.

Show comment
Hide comment
@CamiloCode

CamiloCode Sep 26, 2017

@jan-molak thanks ! ill test it

CamiloCode commented Sep 26, 2017

@jan-molak thanks ! ill test it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment