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)