Home  >  Article  >  Web Front-end  >  js gets content instance sharing of pseudo element

js gets content instance sharing of pseudo element

小云云
小云云Original
2018-01-20 17:30:051533browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn