Handle sticky eleme...
Clear all

[Solved] Handle sticky elements

New Member Guest
Joined: 2 years 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 .

Amrita Kaur
Member Admin
Joined: 4 years ago
Posts: 108

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" = "absolute";
	// = "relative";
    if (position === "fixed") {
        // If the element has "position: fixed", set "position" to "relative" = "absolute";
	// = "relative";


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


This post was modified 2 years ago by admin