3

Is their any way to disable sticky headers/footers/content for testing purpose

i want to take entire web page screen shot like browser extensions. like fireshot if you know please suggest me.

jse.executeScript("var el = document.getElementsByTagName('*');"
                                    + "for(var i = 0; i < el.length; i++){"
                                    + "   if (el[i].getAttribute(\"type\") == \"text/css\")"
                                    + "         el[i].parentNode.removeChild(el[i]);"
                                    + "};"
                                    );

Iam able to disable all css. but my problem is not to disable entire css only fixed/sticky header my previous question

ArrayList<RemoteWebElement> totalElements = (ArrayList<RemoteWebElement>) jse.executeScript("var x = document.querySelectorAll('*');"
            + "for (var i = 0; i< x.length; i++) {"
            + "if (x[i].style.position == 'fixed' || x[i].style.position == 'absolute' || x[i].style.position == 'relative') {"
            + "x[i].style.position = 'static'"
            + "}"
            + "}"
            + "return x");

i am using this but not working as expected.

Community
  • 1
  • 1
Yash
  • 9,250
  • 2
  • 69
  • 74

1 Answers1

2

What if you override only the header's css attribute? Like:

((JavascriptExecutor) yourDriver).executeScript("document.getElementById('the_id_of_the_header').style.position = 'static';");

UPDATE:

Try this javascript code:

var elems = document.body.getElementsByTagName('*'); 
for(i = 0; i < elems.length; i++) 
{ 
  var elemStyle = window.getComputedStyle(elems[i]);
  if(elemStyle.getPropertyValue('position') == 'fixed') 
  { 
    elems[i].style.position = 'static'; 
  } 
}

If you want to check more value just extend the if statement.

peetya
  • 3,578
  • 2
  • 16
  • 30
  • we did't know that site is using inline/internal/external css and the id-of header is unknown. We need to find all sticky headers/contents of any site for testing. Thanks for your response. – Yash Jul 14 '15 at 10:35
  • @Yash: I updated my comment, please check it. I tried that with different values and it worked for me. – peetya Jul 14 '15 at 11:22
  • 1
    @Yash: the problem is with this site that a new CSS class get added after scrolling. So you should execute the JS code after scrolling down and it will work. – peetya Jul 14 '15 at 12:34