javascript - Get css value by CSS and use in Selenium -


i try website attribute (colour of cell) , compare in selenium.

when put this:

javascript:window.getcomputedstyle(document.getelementbyid("simple_cname"),null).getpropertyvalue("background-color"); 

in chrome omnibox, receive correct answer, when i, using storeeval or asserteval try value not work correctly.
edit: put selenium command this. use storeeval , when echo value returns me command. use firefox. used chrome chech if command correct. (it should "rgb(220, 22, 92)" ) edit2: yes, command ok, have problem using in selenium-ide tool. not returns value when use storeeval command. log: [info] script is: var test javascript:window.getcomputedstyle(document.getelementbyid("simple_cname"),null).getpropertyvalue("background-color"); echo test; [info] executing: |echo | ${test} | | [info] echo: var test javascript:window.getcomputedstyle(document.getelementbyid("simple_cname"),null).getpropertyvalue("background-color"); echo test;


i put selenium command this. use storeeval , when echo value returns me command. use firefox. used chrome chech if command correct. (it should "rgb(220, 22, 92)" )

you need remove javascript: part , refer document window.document. command this:

window.getcomputedstyle(window.document.getelementbyid('simple_cname'),null).getpropertyvalue('background-color'); 

the javascript: part needed when running code url bar, it's redundant anywhere else. use console instead of omnibox run js commands in chrome.

the document -> window.document thing mentioned in the docs under storeeval section.

also, note script work in modern browsers, fail in ie < 9. if you're okay it, fine. if not, google has solution.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -