My locators are all hard-coded into the tests. How can I extract these into variables?
1 Answer
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:
you point to the file with SeleniumIDE -> Options -> Options and then point to the file as follows: