Home > Software design >  How to separately send email to the form
How to separately send email to the form

Time:12-01

I made web contact form, my email sending to subscribe email box , I want to send email to the form only. Please help me

driver.get('https://shop.rtrpilates.com/')
driver.find_element_by_partial_link_text('Contact'),click
try:
    username_box = driver.find_element_by_xpath('//input[@type="email"]')
    username_box.send_keys("[email protected]")

I don't understand how can I create a block between this, Help please Advance thanks

CodePudding user response:

Seems you main problem here is that you trying to use deprecated methods find_element_by_*. None of these is supported by Selenium 4.
Also code you shared is missing delays to wait for elements to become clickable etc.
The following short 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(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 10)

url = "https://shop.rtrpilates.com/"
driver.get(url)

wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".header__inline-menu a[href*='contact']"))).click()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".contact__fields input[type='email']"))).send_keys("[email protected]")

The result is

enter image description here

  • Related