dimanche 30 mai 2021

Selenium not able to find element

Hi guys I'm trying to find an element in a website but for some reason it doesn't let me. The webpage is the login form of Reddit, I try to enter my username and my password but when I list all the inputs it only appears the top search bar. I suppose it is because It's like in another "tab" like that it pops up to the front but I don't know how to manage it. Thanks in advance.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(chrome_options=chrome_options)

driver.get('https://www.reddit.com')
driver.set_window_size(1200, 1300)

login_button = driver.find_element_by_link_text('Log In')
login_button.click()

username = driver.find_element_by_css_selector('input')
username.send_keys("test code to the form")



Aucun commentaire:

Enregistrer un commentaire