I am currently dabbling in Python in combination with Selenium. Here I came across the topic of Java Script buttons. I am looking for the smartest way to find out how to execute a Java-Script code (in this case a button) the easiest way.
My goals:
- Open web page
CodePudding user response:
The element Jetzt berechnen is within #shadow-root (open) and is an
<input>
element.
Solution
To click on Jetzt berechnen you can use the following line of code:
berechnen_button = browser.execute_script("""return document.querySelector('kredit-rechner').shadowRoot.querySelector('input.calculator__submit-button')""") berechnen_button.click()