# Mobile testing - using css selector

**URL:** <https://forum.katalon.com/t/mobile-testing-using-css-selector/62470>\
**Category:** Mobile Testing\
**Tags:** mobile-testing, katalon-studio\
**Created:** [February 13, 2022, 7:11pm UTC](https://forum.katalon.com/t/mobile-testing-using-css-selector/62470 "2022-02-13T19:11:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![apooja](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/apooja/32/16104_2.png) [@apooja](https://forum.katalon.com/u/apooja)\
**Post date:** [February 13, 2022, 7:11pm UTC](https://forum.katalon.com/t/mobile-testing-using-css-selector/62470/1 "2022-02-13T19:11:51Z")

</div>

how to verify the button color using css selector in katalon mobile testing…there is no keyword in katalon to verify color also css values not accepted ?

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 13, 2022, 7:43pm UTC](https://forum.katalon.com/t/mobile-testing-using-css-selector/62470/2 "2022-02-13T19:43:24Z")

</div>

CSS selectors are accepted in Katalon. Your problem is two-fold:

1. CSS style properties are not properties/attributes of the element, but, rather, properties of the style object which itself is a property of the element.

2. The CSS style properties can change/evolve throughout the lifetime of the page. So the _specified_ color could change due to interaction with the page itself.

The solution is to use JavaScript and dig out the _current, live_ setting by using `getComputedStyle()`.

On desktop, when the following JavaScript is placed in the developer console for _this page_ (the one you are reading right now), it will return `rgb(23, 121, 222)`

 

```javascript
getComputedStyle(document.querySelector("#ember6 header.d-header")).backgroundColor

```

 

To use that JavaScript code in Katalon (in Groovy) …

 

```javascript
String js = 'return getComputedStyle(document.querySelector("#ember6 header.d-header")).backgroundColor;'
String bgColor = (String) WebUI.executeJavaScript(js, null)
println bgColor

```

 

While you can use WebUI on mobile, I’m not sure if `WebUI.executeJavaScript` is supported by mobile webdrivers – you will have to test it.

---

<div class="post-metadata">

**Author:** ![Dan\_Bown](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dan_bown/32/20464_2.png) [@Dan\_Bown](https://forum.katalon.com/u/Dan_Bown)\
**Post date:** [February 14, 2022, 1:46pm UTC](https://forum.katalon.com/t/mobile-testing-using-css-selector/62470/3 "2022-02-14T13:46:21Z")

</div>

I see you also visited the page I was going to link you to! [[mobile] Can't check color, font size](http://forum.katalon.com/t/mobile-cant-check-color-font-size/15935)  
No idea whether there have been any developments in the years since that thread but this more recent answer on SO does not give confidence. If anyone knows an update, I’d be interested to hear. Seems pretty important to me.  
[https://stackoverflow.com/questions/70534044/get-css-property-via-appium](https://stackoverflow.com/questions/70534044/get-css-property-via-appium)

---

<div class="post-metadata">

**Author:** ![apooja](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/apooja/32/16104_2.png) [@apooja](https://forum.katalon.com/u/apooja)\
**Post date:** [February 16, 2022, 5:50am UTC](https://forum.katalon.com/t/mobile-testing-using-css-selector/62470/4 "2022-02-16T05:50:27Z")

</div>

thanks… webUI is not work for mobile testing i have checked this
