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.
Mumbai Roundup: 9 incidents that took place this week
Photos: Ajay Devgn, Parineeti, Tabu at 'Golmaal Again' trailer launch
Photos: Dipika Pallikal Karthik oozes oomph in bikinis and sarees
Photos: Kareena Kapoor Khan's grand birthday bash
Photos: 'Dangal' girls Sanya Malhotra, Fatima Sana Shaikh's dinner outing