How to introduce custom variable(s) inside driver.execute_script(<HERE>)?
问题 For a web driver we can execute JavaScript code which includes custom variable like this: driver.execute_script("alert('%s')" % variable) # an example introducing variable in alert() But what to do if I need to modify the content of the variable where I have to write the variable inside the script? More specifically, I am facing the following problem: driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") Here in this code, I have to write the document.body.scrollHeight