Python selenium test - Facebook code generator XPATH
This error usually comes if element is not present in the DOM. 
Or may be element is in iframe.
I'm trying to get the XPATH for Code Generator field form (Facebook) in order to fill it (of course before I need to put a code with "numbers").
In Chrome console when I get the XPATH I get:

//*[@id="approvals_code"]

And then in my test I put:

elem = driver.find_element_by_xpath("//*[@id='approvals_code']")
if elem: elem.send_keys("numbers")
        elem.send_keys(Keys.ENTER)

With those I get:

StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

What means wrong field name. Does anyone know how to properly get a XPATH?