The diagram below shows the fretboard pattern for the C major scale in the open position with the scale degrees written in. Practice running through the whole pattern with your eyes closed, visualizing the fretboard in your mind and naming the degrees as you go. Once you can do this easily, try finding various degrees at random until you can do it instantly. Finally, practice improvising melodies with your eyes closed, stopping suddenly and naming the degree you finished on. Keep working on this until you can do it easily.