- Borisman
- Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia
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.
Thanks before.
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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
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
- Borisman
- Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia
Re: Get CSS value
Fri Jan 17, 2014 8:32 am
Could you give me an example from this code ?
HTML :
CSS :
#div1
{ font-size: 12em; }
Thanks before.
HTML :
- Code:
echo <<<HTML
<div id="div1">text</div>
HTML;
CSS :
#div1
{ font-size: 12em; }
Thanks before.
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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}
storeValue| id=div1| variable
echo | ${variable}
- Borisman
- Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia
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 ?
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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
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
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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.
- Borisman
- Posts : 5
Join date : 2014-01-16
Age : 31
Location : Indonesia
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 ?
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 ?
Permissions in this forum:
You cannot reply to topics in this forum
|
|