为什么硒随机返回不是我尊重的结果?

2024-10-03 02:35:43 发布

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

如果网站是http://xkz.cbirc.gov.cn/jr/,reflush它,您将找到确认消息框

driver.get("http://xkz.cbirc.gov.cn/jr/")
wait = WebDriverWait(driver, 10)

table_yanZhengMa = wait.until(
                EC.presence_of_element_located((By.XPATH, "/html/body/div[5]/table"))

visibilityMy = driver.find_element_by_id("show_msg").get_attribute('style')

print(visibilityMy)

if (visibilityMy.find("visibility: visible") >= 0):

    print("需要输入验证码")
else:

    tmpPrice = wait.until(
        EC.presence_of_all_elements_located(
            (
                By.XPATH,
                "/html/body/div[3]/div/div[2]/div/div[1]/div/div[1]/div[2]/div/div[1]/table/tbody/tr/td[5]/div/a"#"//div[@class='sku-name']",  价格
            )
        )
    )

    print(tmpPrice[0].text)

    print(driver.find_element_by_id("queryResult").text)

enter image description here


Tags: divhttpgetdrivertableelementfindcn
2条回答

您可以刷新页面以执行此操作

driver.get("http://xkz.cbirc.gov.cn/jr/")
wait = WebDriverWait(driver, 10)

while True:
    table_yanZhengMa = wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/div[5]/table")))
    print(table_yanZhengMa)
    visibilityMy = driver.find_element_by_id("show_msg").get_attribute('style')  
    print(visibilityMy)
    if(visibilityMy.find("visibility: visible")>=0):
        print("需要输入验证码")
        break
    driver.refresh()

问题解决了,因为我使用Firefox浏览器。如果我使用chrome,这个问题就不会再出现了。但是为什么firefox会导致这个问题,我不知道!有人知道吗

相关问题 更多 >