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

The information is not being stored in Excel despite the fact that the Excel document has been generated with a header

I have been working on a project that involves fetching book details from the Google Books API and using generative AI to create descriptions for them. I have successfully created an Excel file, but I am facing an issue with saving data inside it. It' ...

Develop a circular carousel using React JS from scratch, without relying on any third-party library

I am looking to replicate the carousel feature seen on this website. I want to mimic the same functionality without relying on any external libraries. I have found several resources explaining how to achieve this. Most suggest creating duplicate copies o ...

Regex with Selenium IDE and Square Brackets

Currently, I am working with the Selenium IDE and encountered an issue when trying to select a dropdown element. The target provided in the IDE is: id=ship[0][227587][occasion] The problem is that the value 227587 is dynamic and changes each time. Theref ...

Challenges with Hashmaps

Restructured the getTypeString method in the Flowers class to retrieve object references I'm currently working on a project as part of my coursework and I've encountered the need to utilize a HashMap. Within this Java class, I am attempting to d ...

Unable to locate a suitable retrieval method for the private boolean field in OrmLite

While working on my Android application with OrmLite, I encountered sporadic crashes with an error message indicating a problem with a missing getter method. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app/com.app.MainActivity_ ...

delete the initial background color assigned to the button

The "ADD TO CART" and "save design" buttons are currently displaying as shown in the image below. I would like to make the "SAVE DESIGN" button look similar to the "ADD TO CART" button, meaning I want to remove the background-color and dot symbol. Code ...

What would you name this particular element?

I want to create a unique slider design but I'm unsure where to begin or how to search for information because I don't know the correct terminology. Does this type of slider have a specific name? I heard about Marquee, but that seems like someth ...

Issues encountered with chromedriver version 78.0.3904.70 regarding locating elements on the webpage

Currently utilizing the most recent version of chromedriver 78, I am attempting to locate an element within a modal using a CSS Selector that resembles the following: [data-qa='generalTab'] > [id='ui-id-1'] , Previously, my test ...

The Date validation script in Javascript is malfunctioning

I encountered an issue where the script I used in my HTML file didn't work as expected. The purpose of this script was to prevent users from submitting a date greater than today's date. Interestingly, when I copied the same script to another HTML ...

Strategies for addressing the issue: SessionNotCreatedException occurs when a new session cannot be initiated. This error may be due to an incorrect remote server address

Hi everyone, I'm completely new to using Appium and testing in general. I'm currently experiencing an error that I am unsure how to resolve. Any help would be greatly appreciated. My goal is to test an application on my android studio emulator, ...

Extracting the contents of a Span tag that lacks a class attribute and is not present in every element

I am currently utilizing Selenium in Python to scrape a review page on the web. Specifically, I am interested in extracting the rating of each review (for example, extracting 7 from 7/10 in a review). The structure of the HTML element looks like this: ...

Bluetooth connection isn't providing input data to InputStream

MCVE-EDIT 1: I included my entire code in the main question, but I was asked for an MCVE- The issue is that the device is not receiving any data sent to it by another connected Android device. The code stops running past "inputStream.read(buffer)" becaus ...

How to extract the title of the third window with Selenium Webdriver in Java

My Scenario is: I start with the base URL: www.****.com After opening the URL, I click on a link labeled "Test". This opens another window, let's call it Window B. In Window B, I then click on button "button1", which in turn opens another window nam ...

Utilizing CSS classes to style custom day templates in ng-bootstraps datepicker

Currently, I am utilizing ng-bootstraps datepicker to showcase user data on a daily basis. I have implemented a custom day template to apply specific CSS classes. <ng-template #customDay let-date> <div class="custom-day" [ngCla ...

What is the best way to ensure that all my table images are uniform in size?

Despite creating a table with images all sized 150x150px, I am encountering some inconsistencies where certain images appear larger or smaller than others. Interestingly, when I input the code into JSFiddle, everything appears to be working properly. Howe ...

Unable to import Google Cloud Message Service in Android Studio on OS X

Currently facing a challenge in Android Studio as an iOS developer making the switch to Android. My goal is to create a basic webView app with push notifications. In my mainActivity.java, I noticed that the import statement appears in gray and the checkPl ...

Guide on extracting Twitter followers through Selenium

Is there a way to scrape all Twitter followers at once instead of just one? I don't mind scrolling down the page if needed. browser.get(f"https://www.twitter.com/{username1}/following") time.sleep(5) followers = browser.find_elements_by_xpath('/h ...

An image spanning two columns on a page with three columns

I am currently utilizing Foundation 4 for my website design. I am attempting to create an image that spans over 2 columns in a 3-column layout using the Foundation grid system. Here is how I envision it: I am wondering if it is possible to achieve this by ...

"Efficiently Triggering Multiple Events with One Click in JavaScript

Hey everyone, I could use some assistance. I'm trying to execute multiple events with a single click. Currently, I can change the image in my gallery on click, but I also want to add text labels corresponding to each image. Whenever I click on a diffe ...

Is there a way to determine the exact number of pixels being utilized by the body tag when it is set to 100% width?

Currently working on designing a website with a fluid layout. Trying to utilize percentages as measurements in order to achieve this. From my understanding, percentages are calculated based on the parent element. Given that HTML tags do not have a set widt ...