Home > Article > Web Front-end > Use js to get the content instance sharing of pseudo elements
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, we sometimes encounter the anti-crawler mechanism. Some elements use pseudo-elements, so that they cannot be located when locating the elements. At this time, we need to use js to help locate and obtain the desired information. The required elements
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:
Detailed explanation of the file_put_contents function in PHP
Detailed explanation of CSS content attribute
CSS3 content attribute implementation steps
The above is the detailed content of Use js to get the content instance sharing of pseudo elements. For more information, please follow other related articles on the PHP Chinese website!