【发布时间】:2023-02-24 08:53:05
【问题描述】:
我试图在检查中单击没有 id 的按钮。我正在使用 Python 和硒。我正在尝试使用按钮的类,但未单击“搜索”按钮。我不确定要使用什么其他解决方案。我在这个论坛上看过其他类似的问题,但他们的解决方案对我不起作用。 该网站是 nerdwallet.com。该按钮是绿色搜索按钮。我附上了图片。 请让我知道要使用什么解决方案。谢谢。干杯Nerdwallet Search Button
import webbrowser
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import time
futm_medium=cpc&futm_source=google&futm_campaign=183513080~12071138480&futm_term=finder~e~g~kwd-36367991&futm_content=~~EAIaIQobChMI_6XorNur_QIVLZlmAh3HLQVtEAAYASAAEgIc6fD_BwE&gclid=EAIaIQobChMI_6XorNur_QIVLZlmAh3HLQVtEAAYASAAEgIc6fD_BwE'
options= Options()
options.add_experimental_option("detach", True)
web=webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options)
web.get('https://www.nerdwallet.com/?trk=nw_gn_5.0')
Name="credit card"
cl=web.find_element("xpath",'//*[@id="global-nav"]/div[2]/div[1]/button')
cl.click()
find=web.find_element("xpath",'//*[@id="searchInput"]')
find.send_keys(Name)
bu=web.find_element(By.CLASS_NAME, "_1_LcAp _2nYXVh _1J48pr")
bu.click()
【问题讨论】: