【问题标题】:No Progress after Click on Search Button点击搜索按钮后没有任何进展
【发布时间】:2019-04-12 10:17:39
【问题描述】:

我正在使用 selenium 进行网络抓取任务并停留在点击功能上。

网站步骤:
1. 打开网站
2.在搜索文本框中输入Key值
3.点击搜索开始搜索过程

在第 3 步之后应该加载进度条并开始搜索结果。 但是,点击搜索后,进度条会出现一秒钟然后消失。

我的代码:

browser = webdriver.Chrome(executable_path='C:/Chrome/chromedriver.exe')
browser.set_page_load_timeout(30000)
browser.get("labs.nccgroup.trust/typofinder/")
browser.find_element_by_id('host').send_keys("example.com")
elem=browser.find_element_by_xpath("//*[@id='typogulator']/input[2]")
elem.click()

【问题讨论】:

  • 单击按钮后您的脚本是否会关闭?也许一些测试监听器关闭了浏览器。

标签: python python-3.x selenium web-scraping


【解决方案1】:

在搜索字段中插入值后尝试使用WebDriverWait

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

browser = webdriver.Chrome()
browser.get('https://labs.nccgroup.trust/typofinder')
browser.find_element_by_id('host').send_keys("example.com")
ele=WebDriverWait(browser,20).until(EC.element_to_be_clickable((By.XPATH,"//input[@type='submit'][@value='Search']")))
ele.click()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-24
    • 1970-01-01
    • 1970-01-01
    • 2019-11-13
    • 1970-01-01
    • 2018-11-18
    相关资源
    最近更新 更多