Python issue with element

LADA

Junior Member
Joined
May 28, 2024
Messages
154
Reaction score
48
Working with Selenium

When trying to log into a social network ( https://www.reddit.com/login/ ) , the Log In button does not work. I can't extract the correct element, even though I tried using XPath, but it seems they have some protection in place.

In such cases, what should I do if even XPath doesn't help?
 
I tried every selector that is possible, it doesn’t work, maybe I’m doing something wrong , but Reddits protection seems to work, I wonder, there must be some solution
Can you trigger the click inside the browser's console via js? If so, thats a starting point.

With puppeteer you can execute any js inside the page, i think selenium must be the same? Never used selenium.
 
Have you tried sending the enter key on the password box after typing the password?

Idk the specific selenium code to do it but as a human, that's what I use on practically every website. Something like:
```
from selenium.webdriver.common.keys import Keys

driver.find_element_by_name("Value").send_keys(Keys.ENTER)```
 
The Button resides within a ShadowDOM / ShadowRoot.
You can solve this by traversing to the element via custom JS within your py script.
Selenium 4 also supports interacting with ShadowDOM natively. Read the doc :)
 
Back
Top