Hey Veena, execute_script is used to execute JavaScript code as you perform test automation with Selenium WebDriver. The syntax is:
driver.execute_script(“javascript code here”)
In the code below, on_click() action of Register is performed by using execute_script() method:
from selenium import webdriver
from time import sleep
driver = webdriver.Firefox()
driver.get("https://www.facebook.com")
driver.execute_script("document.getElementsByClassName('home-cta')[0].click()")
sleep(10)
driver.close()