Reference:
Whenever I need to run test JavaScript I use JavascriptExecutor
but none of the blogs above clarifies how it can be done with it.
I tried:
js.executeScript(".notransition {
-webkit-transition: none !important;
-moz-transition: none !important;
-o-transition: none !important;
-ms-transition: none !important;
transition: none !important;
}");
But it does nothing for me.
Edit:
I tried after the answer provided by @AmerllicA
public void turnOffCss () {
navigate("https://www.bureauofdigital.com");
js.executeScript("*, *:before, *:after {
-webkit-transition: none !important;
-moz-transition: none !important;
-ms-transition: none !important;
-o-transition: none !important;
transition: none !important;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
-o-transform: none !important;
transform: none !important;
}");
}
I put another answer for your exact question on JavaScript Executor
. let's to clarify the JavaScript
code,
style
tag element.id
attribute with style-tag
value.CSS
es I answered in another answer.style
tag.style
to head
tag in DOM
.Now let's write above states to JavaScript
codes:
const styleElement = document.createElement('style');
styleElement.setAttribute('id','style-tag');
const styleTagCSSes = document.createTextNode('*,:after,:before{-webkit-transition:none!important;-moz-transition:none!important;-ms-transition:none!important;-o-transition:none!important;transition:none!important;-webkit-transform:none!important;-moz-transform:none!important;-ms-transform:none!important;-o-transform:none!important;transform:none!important}');
styleElement.appendChild(styleTagCSSes);
document.head.appendChild(styleElement);
With this codes you could import my another answer CSS
es to DOM
. so you can put below string to your JavaScript Executor
:
"const styleElement = document.createElement('style');styleElement.setAttribute('id','style-tag');const styleTagCSSes = document.createTextNode('*,:after,:before{-webkit-transition:none!important;-moz-transition:none!important;-ms-transition:none!important;-o-transition:none!important;transition:none!important;-webkit-transform:none!important;-moz-transform:none!important;-ms-transform:none!important;-o-transform:none!important;transform:none!important}');styleElement.appendChild(styleTagCSSes);document.head.appendChild(styleElement);"
If you wanna revert this action, just use:
document.getElementById('style-tag').remove();
Hope these codes help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With