I am using the following code to input Email address and password, by clicking the continue element.
However I have no idea should I enter driver.switch_to_frame and then webdriver can enter the email and password and click?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options=Options()
options.chrome_executable=path="/Users/janice/Desktop/Algo/Selenium/chromedriver.exe"
driver=webdriver.Chrome(options=options)
driver.get("https://system.arthuronline.co.uk/genieliew1/dashboards/index")
CodePudding user response:
There is no iframe, you can just use the below code:
driver.find_element(By.ID, "username").send_keys("email")
driver.find_element(By.ID, "password").send_keys("password")
driver.find_element(By.XPATH, ".//button[@type='submit']").click()
CodePudding user response:
It's unclear what is the problem you faced with, why your code didn't work.
Maybe you missind delay to wait for elments to be ready to accept input or click action?
Anyway, the following code works:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options = Options()
options.add_argument("start-maximized")
webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(service=webdriver_service, options=options)
url = 'https://system.arthuronline.co.uk/genieliew1/dashboards/index'
driver.get(url)
wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable((By.ID, 'username'))).send_keys("[email protected]")
wait.until(EC.element_to_be_clickable((By.ID, 'password'))).send_keys("thepassword")
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[type='submit']"))).click()
The result is: