Forum

Forum
Handle sticky eleme...
 
Notifications
Clear all

[Solved] Handle sticky elements

New Member Guest
Joined: 3 weeks ago
Posts: 1
Topic starter  

I am dealing with multiple sticky elements to take a non-repetitive full-page screenshot. Updating each element one by one is very time consuming. Is there any way to do this automatically?

I am using java and selenium to run TC's .


   
Quote
Amrita Kaur
Member Admin
Joined: 2 years ago
Posts: 97
 

Run the following code using JavaScript executor:

var elements = document.querySelectorAll("*");

// Iterate through the elements and check for "position: sticky"
for (var i = 0; i < elements.length; i++) {
    var element = elements[i];
    var style = window.getComputedStyle(element);
    var position = style.getPropertyValue("position");
    if (position === "sticky") {
        // If the element has "position: sticky", set "position" to "relative"
        element.style.position = "absolute";
	// element.style.position = "relative";
    }
    if (position === "fixed") {
        // If the element has "position: fixed", set "position" to "relative"
        element.style.position = "absolute";
	// element.style.position = "relative";
    }    
}

 

You can choose on how you want those elements to appear to using relative/absolute positions.

 

This post was modified 3 weeks ago by admin

   
ReplyQuote

Leave a reply

Author Name

Author Email

Title *

Maximum allowed file size is 10MB

 
Preview 0 Revisions Saved