1

My locators are all hard-coded into the tests. How can I extract these into variables?

1 Answer 1

0

Create a file with your locators (that you are using in the 'target' field in this format:

storedVars["css_state_discount_7"] = "css=input[name='auto_policy[state_discount_ids][]'][value=7]";
storedVars["css_vehicle_count"] = "css=select[name='auto_policy[_x][vehicle_count]']";
storedVars["css_vehicle1_auto_year"] = "css=select[name='auto_policy[autos_attributes][0][year]']";
storedVars["css_vehicle1_auto_make"] = "css=select[name='auto_policy[autos_attributes][0][make]']";
storedVars["css_vehicle1_auto_model"] = "css=select[name='auto_policy[autos_attributes][0][vehicle_model]']";
storedVars["css_vehicle1_auto_submodel"] = "css=select[name='auto_policy[autos_attributes][0][submodel]']";
storedVars["css_vehicle1_ownership"] = "css=select[name='auto_policy[autos_attributes][0][ownership]']";
storedVars["css_vehicle1_ownership_input"] = "css=input[name='auto_policy[autos_attributes][0][ownership]']";
storedVars["css_vehicle1_primary_use"] = "css=select[name='auto_policy[autos_attributes][0][primary_use]']";

...

storedVars["eqv_claim_type"] = "Vehicle Hit Animal";
storedVars["eqv_claim_date_month"] = "Aug";
storedVars["eqv_claim_date_year"] = "2014";
storedVars["eqv_claim_insurance_paid"] = "100";
storedVars["eqv_relation_to_primary_driver"] = "Child";
storedVars["eqv_driver2_first_name"] = "john";
storedVars["eqv_driver2_last_name"] = "grimley";

Then, in the Selenium IDE use them in this way:

enter image description here

you point to the file with SeleniumIDE -> Options -> Options and then point to the file as follows:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.