- from selenium import webdriver
- from selenium.webdriver.chrome.options import Options
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.common.exceptions import TimeoutException
- chrome_options = Options()
- chrome_options.add_argument("--headless")
- chrome_options.add_argument("--no-sandbox")
- driver = webdriver.Chrome(options=chrome_options)
- driver.get("https://toolkit.tesco.com/sign-in/")
- try:
- login_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Partner sign-in")))
- login_button.click()
- # Locate the email address field by its name attribute
- username_field = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.NAME, 'email')))
- username_field.send_keys('[email protected]')
- # Locate the password field by its name attribute
- password_field = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.NAME, 'password')))
- password_field.send_keys('Pladmarch11')
- password_field.submit() # Submit the form by pressing Enter
- except TimeoutException:
- print("Timeout error: Unable to locate login elements.")
- driver.quit()
[text] N
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new:
File Description
- N
- Paste Code
- 23 Apr-2024
- 1.27 Kb
You can Share it:
Latest Code Pastes