SELENIUM2 Learning -032-webui Automation Practical Case -030-javascript Application example in Selenium Automation (highlight Element)

Source: Internet
Author: User
Tags border color

During automation scripting, you need to highlight elements (by modifying the border style of the elements), and at the same time, to record the action's element object, before manipulating the element. It is uncommon in practical applications, usually for demonstration purposes, or screen captures when errors occur, for error reporting analysis.

Directly on the yards ...

1     /**2      * 3 * @function Height Light the element4      * 5      * @authorAARON.FFP6      * @versionv1.0.0:autouiselenium main.java.aaron.sele.core Seleniumcore.java Hightlightelementbyid, 2014-11-25 13:45:21 Exp $7      * 8      * @paramId:id9      * @paramcolor:the color of borderTen      */ One      Public voidHightlightelementbyid (string ID, string color) { A         /*JavaScript Scripts*/ -String js = ""; -String message = ""; the          -         if(!CL. Colours.contains (color)) { -Message = Oh.opcusitemargsinvalid (2, "Highlight element border color", color, CL.) COLOURS, 1); -              +              This. Logger.info (message); -              +color = CL. Colours.get ("10"); A         } at          -JS = "document.getElementById" ("+ ID +"). Style.border=\ "3px solid" + color + "\" "; -          -          This. Execjs (JS); -}

At this point, theWebUI automation function test script section 030-javascript in the Selenium Automation application example of five (highlighting elements) successfully completed, I hope this article can give beginners Selenium you a reference. (Application of Ps:jquery in Selenium I also categorized JavaScript, please know! )

Finally, very grateful to the pro-stop, I hope this article can be pro helpful. Warmly welcome the kiss to discuss together and progress together. Thank you so much! ^_^

SELENIUM2 Learning -032-webui Automation Practical Case -030-javascript Application example in Selenium Automation (highlight Element)

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.