Identify the CSS Framework being used in conjunction with Selenium

I have developed a program that crawls through various web pages and conducts tests using Selenium. My current task is to identify which CSS Frameworks are utilized on these websites for statistical analysis. Currently, I am using the FireFox Webdriver to check if there are any .css files linked in the page with specific framework names:

Iterator<WebElement> divWebElementIteratorCSS = webDriver.findElements(By.xpath("//link[@rel='stylesheet']")).iterator();

After locating the .css files, I then verify if the name of the file contains one of the CSS Frameworks I intend to analyze:

if ( src.contains( frameWorkName ) && cssFrameWorks.get( frameWorkName ) == false ) {
    result.addAttribute("Framework", "STRING", frameWorkName);
    result.setPercent( 100 );
    result.setSuccessful( true );
    cssFrameWorks.put( frameWorkName, true );
}

The HashMap 'frameWorkName' stores all the relevant framework names.

However, I am facing an issue: If the site administrator changes the name of the framework's .css file, my test fails! Is there a foolproof method to address this, ensuring that the test works regardless of the filename?

Answer №1

I believe @AaronDigulla's response is quite straightforward.

Another approach that comes to mind is while cycling through those items, perform a GET request on the css file, followed by a brief review of the introductory documentation. For instance, a CSS file could include...

/*  Custom CSS Framework Version X.X
 *  Created by: An Individual
 *  License:
 *    A lengthy license agreement
 */

This method could help address any concerns regarding changes in file names.

Answer №2

There is no foolproof method for identifying the specific CSS or JavaScript frameworks utilized by a website.

If you're fortunate, administrators may utilize global URLs like those provided by jQuery's CDN links.

If individuals start renaming files, one option is to download the CSS file and create a checksum in an attempt to identify it.

However, this approach can be unsuccessful if people frequently change these files—some frameworks, such as wro4j, automatically compile all JavaScript and CSS assets into a single large file.

It is important to question why knowing this information is necessary. Instead of focusing on identifying frameworks and versions, consider examining the actual CSS styles being applied, as they could impact your testing process.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When the direction is set to rtl, special characters that are supposed to be at the

When using the direction property for a label with windows style directory paths containing backslashes, I encountered an issue. The purpose of using direction:rtl; was to display the end part (file names) of the path. However, I found that I am getting th ...

Tips for avoiding cursor sticking in css rotate transform in firefox?

I have a unique challenge in this code where I want the user to grab the black square and rotate it around the inner circle. Check out the code snippet here. While attempting to rotate the square, you might notice that the cursor sometimes gets stuck in ...

Optimizing CSS With jQuery During Browser Resize

I am currently facing an issue with recalculating the height of the li element during window resizing or scrolling. Strangely, on page load, the height is no longer being re-calculated and set to the ul's child height. Here is the code I have written ...

Changing the position of the icon in the bootstrap validator

I'm currently attempting to validate form fields in a web project. The goal is to achieve a specific result, similar to the image below: https://i.stack.imgur.com/EVeJf.png While I have made progress with a simple solution that almost meets the requi ...

Tips for loading a webpage directly to the center instead of the top position

Is there a way to make the page open at a specific div halfway down the page instead of starting from the top? Here is an example: <div id="d1"> <div id="d2"> <div id="d3"> <div id="d4"> <div id="d5"> <div id="d6"> Do ...

What is the best way to target the first child element in this scenario?

Is there a way to target only the p tag with id="this" using .root p:first-child selector? Here is the code snippet: Link to CodePen .root p:first-child { background-color: green; } p { margin: 0; } .container { display ...

The Safari 7.1+ browser seems to be having trouble with the spotlight effect

Why is the CodePen not functioning properly in Safari? Despite working well in Chrome and Firefox, it completely fails to work in Safari 7.1+. Can anyone provide some insights? http://codepen.io/cchambers/pen/Dyldj $(document).on("mousemove", function( ...

Developing a transparent "cutout" within a colored container using CSS in React Native (Layout design for a QR code scanner)

I'm currently utilizing react-native-camera for QR scanning, which is functioning properly. However, I want to implement a white screen with opacity above the camera, with a blank square in the middle to indicate where the user should scan the QR code ...

What causes the image to not appear at the center bottom of the page when using IE for loading?

Why does the loading image not appear at the center bottom of the page in IE? This function loads content when the page is loaded and also loads content when scrolled to the bottom. When you load the page index.php, you will see the loading image at the ...

Set meanmenu to a fixed position

I am currently utilizing the meanmenu plugin to create a responsive menu for mobile devices. My goal is to fix the position of the menu at the bottom of the page so that users can easily access it. However, when I set the position of the meancontainer to ...

"Trouble with image height not scaling correctly in Internet Explorer when using the img tag

I am facing an issue that can be observed by visiting this link using Internet Explorer. Interestingly, everything functions perfectly in all other browsers (although Chrome displays little blue squares next to the images for some unknown reason). Here i ...

Guide to downloading a file using Python, Selenium, and PhantomJS

I am currently facing a challenge where I need to login to a website and download a CSV file from a Linux server in a headless manner. The webpage utilizes JavaScript and is dependent on it for functionality. After conducting some research, I decided to u ...

What are some techniques to ensure a bookmark retains its original style even when the cursor hovers over it?

My CSS skills are limited, so I am facing what may seem like a basic issue. On my website, I have a table of contents with links structured like this: <a href="#user-interface">User interface</a> Additionally, there is a bookmark in another ...

Is there an equivalent of the quit method in Selenium & Chromedriver for PHP webdrivers, or do they only have the close() method? I'm curious about the wire protocol commands used in

If I were to mimic the functionality of Selenium's Java Webdriver's quit() method using a PHP Webdriver or any other programming language, how would I go about it? Is it a JSON wire protocol command or something different? Despite my efforts, I ...

Tips for keeping the DropDown Menu displayed even after moving the cursor away from the targeted element in Material-UI

import React from 'react'; import { makeStyles, Typography, Grid } from '@material-ui/core'; const styles = makeStyles((theme) => ({ root: {}, textStyle: { fontFamily: 'brandon-grotesque-black', tex ...

What is the best way to address a row of hyperlink text located at the top of a webpage?

I have encountered an issue where three rows of text links near the top of a page shift up to the very top when a link is pressed, causing them to obscure a line of text that was already at the top. How can I keep the position of these three rows anchored? ...

Encountering a challenge while attempting to adjust the navigation bar at the top as the user scrolls through the page

I've been working on making the navigation bar stay fixed at the top of the page when the user scrolls, but I'm running into some issues. It seems that certain elements are overlapping the navigation bar, causing them to hide the navigation bar a ...

Break up a list into separate paragraphs and style each word using individual CSS

I have a user-generated paragraph that consists of a list of words separated by commas, such as "dog, cat, hamster, turtle." I want to be able to individually assign attributes to each word in the list. Check out this image for reference In the example i ...

Having trouble publishing project on Vercel because of a naming issue

Whenever I try to deploy a project on vercel, I encounter an error stating that the project name is not valid. The specific error messages are as follows: Error: The name of a Project can only contain up to 100 alphanumeric lowercase characters and hyphe ...

Issues with the AndroidDriver Selenium library and the inability to parse the AndroidManifest.xml file are causing problems

Trying to execute the sample test provided at https://code.google.com/p/selenium/wiki/AndroidDriver#Run_the_Tests on an Android emulator (Mac) is causing issues during the test run. After setting up an emulator and installing the WebDriver APK, creating a ...