java - How to get element color with Selenium -


I want to see the color of an element in an HTML page. The color of this algorithm is set with javascript, see the image

Element can assume 4 values ​​with the devil-id "ab_bencoma 1t 1 skeet", of course only one of them is " Val "Variable Val variable is set by the server in any way, this script displays the elections on every X-second server and updates the value of the value.

I have tried to follow the color of the element:

  WebElement element = wait.until (expected conditions. Submissions (By.id ("ab_banco_M1T1_switch")) ); Element.getAttribute element.getAttribute element.getAttribute ("style") element.getAttribute ("background color") element.getCssValue ("style") element.getCssValue ("color")   < P> With no success, they return "blank" or backgound-colors of the page.  

The only way to get the color is in Xpath / html / body / div / div [2] / div [2] / div [2] / div / div / div / div [3] / div For, if I want green / html / body / div / div [2] / div [2] / div [2] / div / div / div / div / div [2] / div)

but This is not my wish. In fact, Xpath transfers the element, but it does not tell me that the color is red or second, I can only know it by looking at the web page. In other words, I want to use the existing dyed color as a firebug, look at the panel on the right, you can see that element. Style - & gt; Background-color = red When I call the element, .getCssCValue ("background-color") I get backgorund-color of #gor_right_div.

Thank you in advance

You can get element color (background color of element) Are:

  element.getCssValue ("background color");   

You can get element text / caption color by:

  element.getCssValue ("color"); For example, if you want to get the background and text color of the "Sign In" button for LinkedIn, the code is as follows:  
  . Received ("https://www.linkedin.com/"); String Button Color = driver.findElement (By.name ("Submit")). GetCssValue ("background-color"); String buttontextcroller = driver.fid element (by.name ("submit")). GetCssValue ("color"); System.out.println ("button color:" + button color); System.out.println ("text color" + buttontextcore);    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -