Home >Web Front-end >JS Tutorial >js gets content instance sharing of pseudo element
This article mainly brings you an example of using js to obtain the content of pseudo elements. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.
During the testing process, sometimes you will encounter the anti-crawler mechanism. Some elements will use pseudo elements, so that when locating the element, it will not be located. At this time, you need to use js to help with positioning. Get the desired element
The following is part of the code
//使用js获取伪元素的content String script = "return window.getComputedStyle(document.querySelector('.myTips'),':after').getPropertyValue('content')"; JavascriptExecutor js = (JavascriptExecutor) driver; String content = (String) js.executeScript(script); System.out.println(content);
Related recommendations:
html’s special Character-css3 content: How to use "special symbols"
Usage examples of contents() method in jQuery
About the content attribute 9 course recommendations
The above is the detailed content of js gets content instance sharing of pseudo element. For more information, please follow other related articles on the PHP Chinese website!