mcdcorp / opentest

Open source test automation tool for web applications, mobile apps and APIs
https://getopentest.org
MIT License
447 stars 107 forks source link

How can i use document.getElementById and window.getComputedStyle to get properties for pseudo Element #523

Closed vijay214-dev closed 2 years ago

vijay214-dev commented 2 years ago

Hi ,

i am trying to get the css property of the pseudo Element(::before) but getting document is not defined. Could you please hep me

verify_mandatory: function () { var element = document.getElementById("caller_id"); $log(element) var sty= window.getComputedStyle(element ,':before') $log(sty.color) },

TripleG commented 2 years ago

document and window are objects which exist only in browsers. You cannot use them in the test itself, because it runs inside nashorn js engine, which runs inside JVM(not inside a browser), therefore such objects don't exist.

You must execute any document or window callings as a browser script, i.e using ExecuteScript action. Such script is executed inside the browser and you have access to all the JS functionalities/objects of the browser

vijay214-dev commented 2 years ago

Thank You