This could happen when you are in wrong window context. Which portal are you using? If you are using iframe based portal, please confirm if you are switching to the desired iframe before trying to access the elements. Another possibility could be, the page might not be loaded completely when you are trying to access the elements. Make sure that you wait for network state to be idle before accessing. Please share more details if your case is not one among these.
This might be the issue with the iframes in Pega version which does't uses cosmos UI. You need to switch to the right frames before performing any action on the webelements other reason would be Webdriver configuration.