Here another attempt of an answer:
I think the main question is how people did know let say how many grams of e.g. silver correspond to 1 mole without being able to count the number of atoms.
The point is that chemists observed already in the 18th century, the law of constant proportions, e.g. that the ratio of the masses of hydrogen and oxygen in a compound like water is a constant.
See the article on the law of definite proportions:
https://en.wikipedia.org/wiki/Law_of_definite_proportions
Comparing the ratios of thousands of compounds, they worked out the smallest consistent set of coefficients, which led to the assignment of molar masses "gram atom" and of stochiometric molecular formulas like H2O for water. This process predated the atomic hypothesis and led at the same time to its formulation and acceptance. However, the atomic hypothesis was still not completely accepted even at the end of the 19th century (specifically by positivists like Ernst Mach). Once the atomic hypothesis was accepted, the masses of the elements containing the same amount of atoms where known precisely although the absolute number of atoms was not well known (order of magnitude estimates were first derived in 1865 by Josef Loschmidt).
Specifically, it was known that e.g. the charge of electrons, necessary to deposit 1 mole of Silver (which was known to weigh 107,9 g), is 96485 Coulomb, the Faraday constant, and that therefore 1 mole of electrons corresponds to 96485 Coulomb.