the problem is as follows: the page input CAPTCHA is correct and the query result will jump, if the query result is not found, the pop-up window (such as below), and the input error will also pop-up window (the text content of the two pop-up windows is different). How to get the text content of the pop-up window with no query result and the wrong pop-up window of CAPTCHA, and then perform the corresponding operation according to the content of the pop-up window.
Code condition: python3
browser =webdriver.Chrome()
browser.get("http://cet.neea.edu.cn/cet")
input_zkzh = browser.find_element_by_id("zkzh")
input_zkzh.send_keys("example")
input_zkzh = browser.find_element_by_id("name")
input_zkzh.send_keys("example")
browser.execute_script("javascript:result.verifys()")
-sharp()...
time.sleep(10)
button =browser.find_element_by_id("submitButton")
button.click()
time.sleep(1)
-sharp()....
I try to use the following code to deal with the pop-up window, which can realize the operation of the pop-up window, but cannot perform the corresponding operation according to the content of the pop-up window. Moreover, if the web page is successfully redirected, it will report an error, and there will be an error when querying the answers obtained by Baidu and Google, but there is an error when dealing with alert, but I can"t solve it.
al = browser.switch_to_alert()
al.accept()
-sharp
...
selenium.common.exceptions.NoAlertPresentException: Message: no such alert
(Session info: chrome=67.0.3396.87) (Driver info: chromedriver=2.39.562718
(9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.17134 x86_64)
I hope that friends who have dealt with similar situations can help me, or tell me if there is a module outside selenium that can be implemented. Thank you very much!