Hi everyone
In configuration page some colors are customizable.
I am trying to access the hex value of the preview color. After some reading, this is what I came up with:
(I have noticed that swatch value shows up as Hex in Chrome but as RGB in IE!)
var colorPrimary = page.QuerySelector(".evo-colorind"); var style = page.contentDocument.defaultView.getComputedStyle(colorPrimary, ""); Log.Message(style.background-color);
I am getting JavaScript runtime error 0x80020101 at 'style' var. Any help deeply appreciated.
I am surprised that even the Smartbear support team is surprisingly quiet! Does this mean there is no way TestComplete can do this!!?
Actually, I think the difference is beyond even just whether or not it shows as RGB versus Hex... I have a checkpoint set up that does something similar.... but the caveat that I have is that it will work with IE only. I think the contentDocument property/object or some of the methods and properties of it are only available in IE. That would be where I'd start, to put a breakpoint on that line and do some investigation as to why JavaScript is burping there...
Thanks Robert!
You are always there when I need help! I almost gave up hope. I will give it a try tomorrow and let you know.
Dave
Hi Robert,
As you suggested, I am using IE 11. Now I am getting runtime error:
var style = page.contentDocument.defaultView.getComputedStyle(colorPrimary, ""); Log.Message(style.background-color);I am not quite sure if I should be using
In the code that I'm using, I get the element from the page in IE... then I get the "currentStyle.backgroundColor" property. I think that's better than the getComputedStyle method. See if that works better for you.
Thank you. I will give it a try.
I used:
var style = page.contentDocument.defaultView.currentStyle.backgroundColor(colorPrimary, "")
as you suggested.
I am getting:
backgroundColor is not a method, it's the actual property. So, just compare that property to the desired value.
Hi Robert
Thank you for the clarification.
User | Count |
---|---|
36 | |
14 | |
10 | |
8 | |
7 |
Subject | Author | Latest Post |
---|---|---|