Divorce does not take place when one merely thinks about it
Question

                I made divorce conditional upon my not doing a specific action, then I swore an oath by Allaah that I would not do this action. This is something that I thought about to myself, with no real intention of doing it, and I did not utter it with my tongue. Then I did the thing that I had sworn not to do, because I was certain, if Allaah wills, that divorce would not happen unless it was spoken. I asked about this matter before because I experience a loss of whispers from the shaytaan. My question is, do I have to do anything? Do I have to offer expiation for breaking an oath because of my oath by Allaah that was in my mind?.
Praise be to Allah.If you did not utter the 
    divorce and the oath, then you do not have to do anything, because thinking 
    to oneself is forgiven, and divorce does not take place if there is only the 
    intention; similarly, an oath is not binding if it was only an intention, 
    rather it must be spoken or something that takes the place thereof such as 
    writing it. Al-Bukhaari (5269) and Muslim (127) narrated from Abu Hurayrah 
    (may Allaah be pleased with him) that the Prophet (blessings and peace of 
    Allaah be upon him) said: “Allaah has forgiven my ummah for whatever crosses 
    their mind so long as they do not speak of it or act upon it.” Qataadah 
    said: if he issues a divorce in his mind, it does not count as anything. 
We have mentioned in a 
    previous answer that the divorce of a person who is affected by whispers 
    from the shaytaan does not count as anything even if he utters it, according 
    to some of the scholars, so long as he did not intend divorce. Shaykh Ibn 
    ‘Uthaymeen (may Allaah have mercy on him) said: The divorce issued by one 
    who is suffering from whispers from the shaytaan does not count as such even 
    if he utters it with his tongue, if it was not done intentionally, because 
    this utterance happened as the result of the waswasah without there being 
    any intention or will on his part; rather he was forced to do it because of 
    the strength of the impulse and weakness of resistance. The Prophet 
    (blessings and peace of Allaah be upon him) said: “There is no divorce in 
    the case of compulsion.” So no divorce has taken place if he did not really 
    intend it with certainty. This is something that may be forced upon him with 
    no intention or choice on his part, so it does not count as a divorce. End 
    quote from Fataawa Islamiyyah (3/277). 
To sum up: nothing is 
    binding upon you, whether it be a divorce or expiation for breaking an oath, but you should deal with the whispers from the shaytaan by remembering Allaah a great deal, doing righteous deeds, and turning away from the whispers and not paying any attention to them. 
And Allaah knows best.