Basically, I am writing a script, that should open a specific URL on chrome, press certain buttons, login, press another button, and terminate chrome.
until now, it was pretty easy to do, because every button or field I needed had its own ID's.
Now, I have to press on a button, that does not have the ID and I am not sure how to do it.
here is my code.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pyautogui
import time
browser = webdriver.Chrome('XXX')
browser.get("XXX")
details_bttn = browser.find_element_by_id('details-button')
details_bttn.click()
proceed_bttn = browser.find_element_by_id('proceed-link')
proceed_bttn.click()
username = browser.find_element_by_id('login_name')
username.click()
username.send_keys('XXX')
password = browser.find_element_by_id('login_password')
password.click()
password.send_keys('XXX')
password.send_keys(Keys.ENTER)
I tried to do it with Xpath but it did not work, because the button only lit up, but it was not clicked. It is my first time working with python, so I definitely lack experience.
question from:
https://stackoverflow.com/questions/66060590/how-to-click-on-a-button-without-id-using-python-selenium 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…