A man has faced a Perth court charged over an alleged sex attack on an elderly lady in Mandurah.

A man gained entry into the woman's Greenfields home in the early hours of Sunday.

Police allege the woman in her 80s was home alone in her Greenfields home in the early hours of Sunday when a man gained entry, startling the elderly pensioner.

A police spokesman said it will be alleged the man grabbed the woman and attempted to sexually assault her before leaving.

“As a result of the assault, the elderly woman received bruising and abrasions to her face and swelling to her hand,” he said.