This is a migrated thread and some comments may be shown as answers.

Get all styles of a control

3 Answers 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Amey
Top achievements
Rank 1
Amey asked on 11 Feb 2013, 03:14 AM
Hi,

When I navigate to  ActiveBrowser.NavigateTo("http://www.gmail.com");
and try to find the styles applied on sign in button
HtmlInputSubmit btn = Find.ById <HtmlInputSubmit>("signIn");
HtmlStyle btnStyles = btn.GetComputedStyle("font-size");

it  does not return anything.

I have  2 questions
1. Is this the right way to find out the  styles applied on a control
2.If not, can you please tell me the right way to find out a style property of a control.

Thanks,
Amey.

3 Answers, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 11 Feb 2013, 10:59 AM
Hello Amey,
try this code for IE:
ActiveBrowser.NavigateTo("http://www.gmail.com");
HtmlInputSubmit btn = Find.ById<HtmlInputSubmit>("signIn");
String fSize = btn.GetComputedStyleValue("fontsize");
Log.WriteLine(fSize);

and try this code in Chrome:
ActiveBrowser.NavigateTo("http://www.gmail.com");
HtmlInputSubmit btn = Find.ById<HtmlInputSubmit>("signIn");
String fSize = btn.GetComputedStyleValue("font-size");
Log.WriteLine(fSize);

The property is called fontsize in IE and font-size in Chrome.

I hope this helps.

Greetings,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Amey
Top achievements
Rank 1
answered on 11 Feb 2013, 05:28 PM
Thanks a lot for your answer.
Hope Mozilla has the same approach like Chrome.



Regards,
Amey.
0
Stoich
Telerik team
answered on 14 Feb 2013, 01:09 PM
Hello,
for Firefox try the following code:
ActiveBrowser.NavigateTo("http://www.gmail.com");
System.Threading.Thread.Sleep(2000);
ActiveBrowser.RefreshDomTree();
             
HtmlControl btn = Find.ByName<HtmlControl>("signIn");
             
btn.AssertStyle().Font(ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts.HtmlStyleFont.Size,"13px");
            

This will check the value for font size and assert the number.

Greetings,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Amey
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Amey
Top achievements
Rank 1
Share this question
or