Namespace: getCssValue

getCssValue

getCssValue(driver, path, cssProperty, timeopt) → {Object|Error}

getCssValue

Parameters:
Name Type Attributes Description
driver Object

webdriver object of web browser.

path Object

object of path type as xpath, id, className, tagName, name properties.

cssProperty String

Attribute of css of Html element we want to get.

time Number <optional>

time is optional.This parameter represent for how much time user want to wait for "webElement". After time finish it returns error.

Returns:

returns Object of webElement & value. If we pass time param & it will not get "webElement", it will return error.

Type
Object | Error

Examples

Examples usage of getCssValue by HTML element xpath

 getCssValue(driver, { xpath: '//*[@id="testXpath"]/div' }, 'font-size').then((webElement) => {
   // font-size is the css attriute whose value we want to get.
   // After resolve promise We'll get the "webElement" object for HTML element whose "xpath" we pass.
   // By the help of "webElement" we get css attriute value of HTML element.
 }).catch((error) => {
   // handle error
 });

Examples usage of getCssValue by HTML element id

 getCssValue(driver, { id: 'testId' }, 'font-size').then((webElement) => {
   // font-size is the css attriute whose value we want to get.
   // After resolve promise We'll get the "webElement" object for HTML element whose "id" we pass.
   // By the help of "webElement" we get css attriute value of HTML element.
 }).catch((error) => {
   // handle error
 });

Examples usage of getCssValue by HTML element class

 getCssValue(driver, { className: 'testClass' }, 'font-size't).then((webElement) => {
   // font-size is the css attriute whose value we want to get.
   // After resolve promise We'll get the "webElement" object for HTML element whose "classname" we pass.
   // By the help of "webElement" we get css attriute value of HTML element.
 }).catch((error) => {
   // handle error
 });

Examples usage of getCssValue by HTML element tagName

 getCssValue(driver, { tagName: 'span' }, 'font-size').then((webElement) => {
   // font-size is the css attriute whose value we want to get.
   // After resolve promise We'll get the "webElement" object for HTML element whose "tagname" we pass.
   // By the help of "webElement" we get css attriute value of HTML element.
 }).catch((error) => {
   // handle error
 });

Examples usage of getCssValue by name property of HTML element

 getCssValue(driver, { name: 'testName' }, 'font-size').then((webElement) => {
   // font-size is the css attriute whose value we want to get.
   // After resolve promise We'll get the "webElement" object for HTML element whose "name" property we pass.
   // By the help of "webElement" we get css attriute value of HTML element.
   // Similarly we can access elemets HTML by using any attribute of which used in HTML element.
 }).catch((error) => {
   // handle error
 });