Arun
Arun

Reputation: 875

WebDriver getCssValue is not returing border color

I need to find the border color of a button the HTML properties of the button is like follow

<input class="BUTTON" type="button"  title="Add Link" value="Add Link" name="ADD_LINK"/>

and CSS properties are as follow

background-color: transparent;
    border: 0 solid #EACCAE;
    border-radius: 2px 2px 2px 2px;
    height: auto;
    padding-bottom: 1px;
    vertical-align: text-top;

I am using following code for getting border property

String sColor = driver.findElement(By.xpath("//input[@value='Add Link' and @type='button']")).getCssValue("border");

but its not returning any value. At the same place when I am trying to get the background-color property with code

 String sColor = driver.findElement(By.xpath("//input[@value='Add Link' and @type='button']")).getCssValue("background-color");

it's returning transparent.

Can anyone will please suggest me why I am not getting border property or provide me solution for this.

Thanks

Upvotes: 1

Views: 3676

Answers (1)

dfreeman
dfreeman

Reputation: 2834

The CSS border attribute is actually shorthand for border-width, border-style, and border-color all together. (See the W3 doc.)

If you query each of those styles individually, you should get back the information you're looking for from Selenium.

Upvotes: 2

Related Questions