无法同时使用 Firefox 和 Chrome Webdriver 使用 Python Selenium 触发按钮
Can't trigger a button using Python Selenium using both Firefox and Chrome Webdriver
我需要在网站上抓取尺码表图片。图像放置在弹出窗口中。我正在使用 Selenium Python 来触发 href 并抓取数据。我已附上我的代码以供参考。
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
from time import sleep
url = 'https://www.macys.com/shop/product/jessica-howard-side-twist-sheath-dress?ID=11329706&CategoryID=5449'
driver = webdriver.Firefox()
driver.get(url)
#sizechart_popup = driver.find_elements_by_class_name('sc-link')
sizechart_popup = WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, './/*[@class="sc-link"]'))).click()
print (sizechart_popup)
# Sleep of 10 seconds irrespective of whether element is present or not
time.sleep(50)
# Free up the resources
driver.close()
请帮忙改正。
尝试使用此方法查找元素并单击该特定元素。
WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, '//*[@class="sc-link"]'))).click()
由于某种机器人检测,它 运行 不是 .js 文件。我通过禁用 navigator.webdriver.
来打开它
options = Options()
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(options=options)
wait = WebDriverWait(driver, 10)
driver.get('https://www.macys.com/shop/product/jessica-howard-side-twist-sheath-dress?ID=11329706&CategoryID=5449')
wait.until(EC.element_to_be_clickable((By.XPATH, './/*[@class="sc-link"]'))).click()
导入
from selenium.webdriver.chrome.options import Options
我需要在网站上抓取尺码表图片。图像放置在弹出窗口中。我正在使用 Selenium Python 来触发 href 并抓取数据。我已附上我的代码以供参考。
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
from time import sleep
url = 'https://www.macys.com/shop/product/jessica-howard-side-twist-sheath-dress?ID=11329706&CategoryID=5449'
driver = webdriver.Firefox()
driver.get(url)
#sizechart_popup = driver.find_elements_by_class_name('sc-link')
sizechart_popup = WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, './/*[@class="sc-link"]'))).click()
print (sizechart_popup)
# Sleep of 10 seconds irrespective of whether element is present or not
time.sleep(50)
# Free up the resources
driver.close()
请帮忙改正。
尝试使用此方法查找元素并单击该特定元素。
WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, '//*[@class="sc-link"]'))).click()
由于某种机器人检测,它 运行 不是 .js 文件。我通过禁用 navigator.webdriver.
来打开它options = Options()
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(options=options)
wait = WebDriverWait(driver, 10)
driver.get('https://www.macys.com/shop/product/jessica-howard-side-twist-sheath-dress?ID=11329706&CategoryID=5449')
wait.until(EC.element_to_be_clickable((By.XPATH, './/*[@class="sc-link"]'))).click()
导入
from selenium.webdriver.chrome.options import Options