We propose a new computer-simulation technique; based on the Widom test-particle method; to calculate the chemical potentials of components in a polymeric system. The technique is based on the insertion of test segments onto a polymer and is applicable for any chain length at gas and liquidlike densities. We perform sample calculations on homopolymers and show that the proposed technique allows for the enumeration of their thermodynamic behavior in the subcritical and supercritical temperature ranges.