He actually did consider attacking them, but quickly changed his mind afterwards (split personalities, if you remember). Here's how the inner debate went in The Passage of the Marshes.
He was held by his promise
'I don't know. I can't help it. Master's got it. Smeagol promised to help the master.'
'Yes, yes, to help the master: the master of the Precious. But if we was master, then we could help ourselfs, yes, and still keep promises.'
'But Smeagol said he would be very very good. Nice hobbit! He took cruel rope off Smeagol's leg. He speaks nicely to me.'
"They'll wake up too quick and kill us"
'No, sweet one. See, my precious: if we has it, then we can escape, even from Him, eh? Perhaps we grows very strong, stronger than Wraiths. Lord Smeagol? Gollum the Great? The Gollum! Eat fish every day, three times a day; fresh from the sea. Most Precious Gollum! Must have it. We wants it, we wants it, we wants it!'
'But there's two of them. They'll wake too quick and kill us,' whined Smeagol in a last effort. 'Not now. Not yet.'
Though treacherous, deceitful and a downright liar, Smeagol didn't dare to "directly" attack Frodo. Why? Because he was held by his promise. Only when he learned Frodo was going to destroy the Ring did he bite Frodo's finger off.