Get all styles of a control

4 posts, 0 answers
  1. Amey
    Amey avatar
    2 posts
    Member since:
    Feb 2013

    Posted 10 Feb 2013 Link to this post

    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.
  2. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 11 Feb 2013 Link to this post

    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
  3. Amey
    Amey avatar
    2 posts
    Member since:
    Feb 2013

    Posted 11 Feb 2013 Link to this post

    Thanks a lot for your answer.
    Hope Mozilla has the same approach like Chrome.



    Regards,
    Amey.
  4. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 14 Feb 2013 Link to this post

    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
Back to Top