There's a two step-process to stochiometry.

The first step, as people have elaborated below, is combust the compound and measure the weights of various oxides, which (after the atomic masses of the relevant elements were settled around the 1820s) lets you work out the empirical formula of an unknown molecule. For benzene, this would tell you that there is 1 C : 1 H, but this doesn't tell you if it's C₄H₄ or C₆H₆ or C₁₁₁H₁₁₁.

The second step is to determine the molar mass of your compound, which requires finding something that depends on the amount of substance but not the mass directly. (In modern times, this is primarily mass spec). Back in the 19th century, this is probably abusing the ideal gas law, which lets you compute the number of moles in a gas given the pressure, temperature, and volume of a vessel. Combine this with the mass of that container, and you know how much a mole weighs. If you get out, say, 77g/mol, and you know that the ratio is 1 C : 1 H, well, the only formula that makes sense is C₆H₆ (which should ideally have 78g/mol, but you might not get the right answer for various experimental reasons).