Execute JS code in Selenium-webdriver

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.