Search
 
 

Display results as :
 


Rechercher Advanced Search

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Get CSS value

View previous topic View next topic Go down

Get CSS value

Post by Borisman on 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.

Borisman

Posts : 5
Join date : 2014-01-16
Age : 23
Location : Indonesia

Back to top Go down

Re: Get CSS value

Post by ccox on 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

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: Get CSS value

Post by Borisman on 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.

Borisman

Posts : 5
Join date : 2014-01-16
Age : 23
Location : Indonesia

Back to top Go down

Re: Get CSS value

Post by ccox on 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}

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: Get CSS value

Post by Borisman on Sat Jan 18, 2014 12:03 am

No, what i mean is how to get the font-size value of that css code ?

Borisman

Posts : 5
Join date : 2014-01-16
Age : 23
Location : Indonesia

Back to top Go down

Re: Get CSS value

Post by ccox on 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

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: Get CSS value

Post by ccox on 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.

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: Get CSS value

Post by Borisman on 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 ?

Borisman

Posts : 5
Join date : 2014-01-16
Age : 23
Location : Indonesia

Back to top Go down

Re: Get CSS value

Post by acts79 on Wed Feb 26, 2014 4:31 pm

Finally found this one, thanks for posting. Really Helps

acts79

Posts : 3
Join date : 2014-02-18

http://ny.pe

Back to top Go down

Re: Get CSS value

Post by Sponsored content Today at 3:10 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


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