The 29-year-old beauty faced stiff competition from fellow actresses Judy Greer, Jessica Biel and funnywoman Sarah Silverman for the part of magician's assistant Jane, reported Contactmusic.
"It was a bit of a coup getting this role - it was intended for a comedian. My agent knew I loved comedy, but I was a long shot, the lame horse at the back," she said.
Steve Carell, who is co-producing the movie, said Wilde blew casting directors away with her performance. "Her audition was fantastic. Subtle, but full of detail. She was my immediate first choice," he said.