简体   繁体   中英

python selenium click on button not working correctly, normal click by mouse is OK

I use python to automate tradingview and I remove all alerts and set a new alert but it is not working. There appears a popup with two buttons Yes and No . Manual clicking by mouse is OK but using Selenium to click on the button but is not working.

#Remove all Alert
browser.find_element(By.XPATH,"//div[@data-name='base']").click()
time.sleep(2) 
browser.find_element(By.XPATH,"//div[@data-name='alerts']").click()
time.sleep(2)
browser.find_element(By.XPATH,"//div[@data-name='alerts-settings-button']").click()
time.sleep(2)
browser.find_element(By.XPATH,"//div[@class='item-RhC5uhZw item-YF9HXIe0 withIcon-RhC5uhZw withIcon-YF9HXIe0']").click()
time.sleep(5)
browser.find_element(By.NAME,"yes").send_keys(Keys.ENTER)
#browser.find_element(By.NAME,"yes").send_keys(Keys.ENTER)

Did you try?:

browser.find_element(By.NAME,"yes").click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM