I've been watching youtube videos, but cant seem to get the following to work using the "class method".
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = Options() options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://sharemydata.pge.com/#login")
driver.find_element_by_class_name('input-username').send_keys('david@gmail.com')
https://www.youtube.com/watch?v=rj5zfP3ktgE I watched this guys yt page, but his method byclass name does not seem to work for me. I can only seem to get as far as opening the page.
I also tried this,
driver.find_element_by_xpath("//input[@type='email']").send_keys("david@gmail.com")
To send a character sequence to the User Name field within the website you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:
Using CSS_SELECTOR:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[type='email']"))).send_keys("david@gmail.com")
Using XPATH:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@type='email']"))).send_keys("david@gmail.com")
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC