You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python+Selenium登录Etsy遇ElementNotVisibleException问题求助

Fixing Etsy Login ElementNotVisibleException with Selenium

Hey there, let's tackle this Etsy login problem you're facing! The root issue is that Etsy recently updated their login page to set the email (and possibly password) fields to hidden type, which blocks Selenium's standard send_keys() method since it only interacts with visible elements. Here are two solid workarounds to get your script working again:

1. Inject JavaScript to Set Hidden Field Values

Selenium lets you execute raw JavaScript, which can modify hidden elements directly. This bypasses the visibility check entirely. Here's how to implement it, filling in the gaps from your script snippet:

First, set up your Chrome driver with any custom options you use:

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

# Initialize Chrome with your custom options
chrome_options = webdriver.ChromeOptions()
# Add your existing options here, e.g. chrome_options.add_argument("--headless=new")
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.etsy.com/login")

Then use JavaScript to populate the hidden fields:

# Locate the hidden email field (adjust the locator to match Etsy's current DOM)
email_field = driver.find_element(By.NAME, "email")
# Use JS to set your email value
driver.execute_script("arguments[0].value = 'your_etsy_email@example.com';", email_field)

# Repeat for the password field if it's also hidden
password_field = driver.find_element(By.NAME, "password")
driver.execute_script("arguments[0].value = 'your_etsy_password';", password_field)

# Click the visible login button
login_button = driver.find_element(By.XPATH, "//button[@data-testid='sign-in-button']")
login_button.click()

Pro tip: Use your browser's developer tools (F12) to confirm the correct locator (name, id, or XPath) for the hidden fields—Etsy might tweak these occasionally.

2. Locate the Visible "Proxy" Input Element

Sometimes, websites use a visible input box that syncs its value to a hidden field behind the scenes. Instead of targeting the hidden field, find this visible element and interact with it normally:

First, add imports for explicit waits (critical to ensure elements are fully loaded before interacting):

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

Then target the visible input elements:

# Wait for the visible email input to load and send your username
visible_email_input = WebDriverWait(driver, 10).until(
    EC.visibility_of_element_located((By.CLASS_NAME, "wt-input wt-input--small"))
)
visible_email_input.send_keys("your_etsy_email@example.com")

# Do the same for the password field
visible_password_input = WebDriverWait(driver, 10).until(
    EC.visibility_of_element_located((By.CLASS_NAME, "wt-input wt-input--small wt-input__password"))
)
visible_password_input.send_keys("your_etsy_password")

# Click the login button
login_button.click()

Important Notes

  • Always prioritize interacting with visible elements over using JavaScript—this mimics real user behavior and reduces the chance of triggering anti-bot measures.
  • Etsy frequently updates their UI, so double-check your locators with developer tools if the script breaks again.
  • Use explicit waits (like WebDriverWait) instead of hardcoded sleeps to handle variable page load times.

内容的提问来源于stack exchange,提问作者Lily J

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:28:37