You may be remembering Skylark of Space by E.E. Smith.
On page 1 the genius Richard Seaton accidentally makes a copper bath neutralize gravity, and it flies out the windown and up into space.
He then uses the secret of Metal X to make a spaceship and flies about saving planets and stopping wars. (and committing well-intentioned genocide!)
Petrified with astonishment, Richard Seaton stared after the copper steam-bath upon which he had been electrolyzing his solution of "X," the unknown metal. For as soon as he had removed the beaker the heavy bath had jumped endwise from under his hand as though it were alive. It had flown with terrific speed over the table, smashing apparatus and bottles of chemicals on its way, and was even now disappearing through the open window.
He seized his prism binoculars and focused them upon the flying vessel, a speck in the distance. Through the glass he saw that it did not fall to the ground, but continued on in a straight line, only its rapidly diminishing size showing the enormous velocity with which it was moving. It grew smaller and smaller, and in a few moments disappeared utterly.
The chemist turned as though in a trance. How was this? The copper bath he had used for months was gone—gone like a shot, with nothing to make it go. Nothing, that is, except an electric cell and a few drops of the unknown solution.
You can read download it for free on Gutenberg.
Here's a picture of "Dick" Seaton testing the flying capabilities of his accidental invention.