#Gets the text text value of the labeljs1="return document.getElementById (' Key1 '). InnerText"dr.execute_script (JS1)#gets the HTML text for the labelJs2="return document.getElementById (' Key2 '). InnerHTML"dr.execute_script (JS2)#Enter a value in a single text boxcontent_text="Test"JS3="document.getElementById (' Key3 '). Value = '%s '"%(Content_text) dr.execute_script (JS3)#Enter text text in a multi-text box (Rich text box)js4="document.getElementById (' Key4 '). ContentWindow.document.body.innerText = '%s '"%(Content_text) dr.execute_script (JS4)#Enter HTML text in a multi-text box (Rich text box)js5="document.getElementById (' Key5 '). ContentWindow.document.body.innerHTML = '%s '"%(content_html) dr.execute_script (JS5)#Click the buttonjs6="document.getElementById (' Key6 '). Click ()"dr.execute_script (JS6)
View Code
Note: Firefox browser does not support innertext
Execute JS code in Selenium-webdriver