Home > Web Front-end > JS Tutorial > body text

Use js to get the content instance sharing of pseudo elements

小云云
Release: 2018-01-03 16:22:04
Original
2200 people have browsed it

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!