专注于文本框后按隐藏按钮

时间:2020-07-03 16:34:46

标签: python selenium web-scraping

在此URL中:https://list.tmall.com/search_product.htm?q=%B3%E8%CE%EF%CA%B3%C6%B7&type=p&vmarket=&spm=875.7931836%2FB.a2227oh.d100&from=mallfp..pc_1_searchbutton

我试图按表单上的“提交”按钮,但是它仅在关注start_price文本框或end_price文本框之后出现。

到目前为止,我已经尝试了以下方法:

    WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.NAME, "start_price"))).send_keys(i)
    WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.NAME, "end_price"))).send_keys(i)
    WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.ID, "J_FPEnter"))).click()

,但似乎无法正常工作。 所需的输出将是重定向到这样的URL: https://list.tmall.com/search_product.htm?start_price=1&end_price=1&search_condition=48&sort=s&style=g&from=mallfp..pc_1_searchbutton&q=%B3%E8%CE%EF%CA%B3%C6%B7&shopType=any

谢谢!

1 个答案:

答案 0 :(得分:0)

在发送短信之前先尝试单击,我建议使用element_to_be_clickable代替presence_of_element_located

start_price = WebDriverWait(browser, 20).until(EC. element_to_be_clickable((By.NAME, "start_price")))
start_price.click()
start_price.send_keys(i)
end_price = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.NAME, "end_price")))
end_price.click()
end_price.send_keys(i)
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.ID, "J_FPEnter"))).click()
相关问题