表单提交后Python Selenium陷入循环

2024-04-25 20:02:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个链接列表,我循环通过,在每个链接上我更新百分之二的价格字段

我在最后没有点击元素的情况下进行了一次试运行,一切正常。 当我在最后一行添加click事件时,新链接没有加载,它只是重新加载了相同的页面,并再次更新了2%的价格

for link in sprojs_links:
    current_price = 0
    driver.get(link)
    wait = WebDriverWait(driver, 10)
    submit_button = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="publish"]')))
    price_input = driver.find_element_by_xpath('//*[@id="acf-field_5a7c1700c1e4c"]')
    current_price = price_input.get_attribute('value')
    new_price = math.ceil(float(current_price) * 1.02)
    price_input.clear()
    price_input.send_keys(new_price)
    submit_button.click()

你知道我能做些什么来解决这个问题吗


Tags: idnewinputget链接driverlinkbutton

热门问题