Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
Borisman
Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia

Get CSS value Empty Get CSS value

Thu Jan 16, 2014 5:24 pm
Hi all, i'm very new in Selenium, i would like to ask how to get CSS value with Selenium IDE ?

Thanks before.
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

Get CSS value Empty Re: Get CSS value

Fri Jan 17, 2014 3:45 am
storeValue| css locator | variable

the css locator will be the location at which the variable you are looking to get is.

Then try
echo | ${variable}

That will write what the stored value is in the log
avatar
Borisman
Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia

Get CSS value Empty Re: Get CSS value

Fri Jan 17, 2014 8:32 am
Could you give me an example from this code ?

HTML :
Code:
echo <<<HTML
<div id="div1">text</div>
HTML;

CSS :
#div1
{ font-size: 12em; }


Thanks before.
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

Get CSS value Empty Re: Get CSS value

Fri Jan 17, 2014 10:25 pm
Why are you using the css locator? You have an id.  In my opinion, id's are much better to use.

storeValue| id=div1| variable
echo | ${variable}
avatar
Borisman
Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia

Get CSS value Empty Re: Get CSS value

Sat Jan 18, 2014 12:03 am
No, what i mean is how to get the font-size value of that css code ?
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

Get CSS value Empty Re: Get CSS value

Sat Jan 18, 2014 12:54 am
Try this:

storeEval |window.getComputedStyle(window.document.getElementById('div1'), null).getPropertyValue("font-size"); | variable

echo | ${variable}

This worked for me to get the font-size and all other css variables
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

Get CSS value Empty Re: Get CSS value

Sat Jan 18, 2014 5:10 am
FYI, Selenium IDE doesn't have a built-in function for getting CSS attributes.  However, Selenium IDE is great at executing javascript using the storeEval and getEval commands.  You just have to implement the results of the execution to fit your needs.
avatar
Borisman
Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia

Get CSS value Empty Re: Get CSS value

Sat Jan 18, 2014 11:15 am
It's work! Thanks a lot.

Btw, i have a project which needs to store all HTML element property value, so i need to access not only HTML but CSS and javascript of the web.

Could you give me an advice which selenium i prefer to use to fit that needs ?
avatar
acts79
Posts : 3
Join date : 2014-02-18
http://ny.pe

Get CSS value Empty Re: Get CSS value

Wed Feb 26, 2014 4:31 pm
Finally found this one, thanks for posting. Really Helps
Sponsored content

Get CSS value Empty Re: Get CSS value

Back to top
Permissions in this forum:
You cannot reply to topics in this forum