Trouble verifying if certain elements are showing on page

3 posts, 0 answers
  1. Felix
    Felix avatar
    2 posts
    Member since:
    Jun 2011

    Posted 14 Jun 2012 Link to this post

    Hi all,

    I'm trying to close some slide outs and in page pop ups when they show (they only show after cookies are cleared when you first visit this page)

    I've tried a few things but i'm not getting the results i need. Examples i've found use .isVisible which i couldnt find in my available options.<div class="popup-modal most-visible" style="display: block; z-index: 102; width: auto; height: auto; top: 159px; left: 680px;">
    Here are the 2 snippets of code i want to verify if they are "showing on the page currently"

    <div class="popup-modal most-visible" style="display: block; z-index: 102; width: auto; height: auto; top: 159px; left: 680px;">
    <div class="qsc-popup-dialog" style="display: block; visibility: visible;">
    <div class="close-button" title="Close Dialog"></div>
    <div class="header">Product Type</div>
    <div id="startupHelp" class="body" style="width: auto; height: auto; overflow: auto;">
    <div class="footer">
    <div class="sf-pagehelp" style="left: 0px;">
    <a class="sf-pagehelp-pin" href="#" style="display: none;"></a>
    <div class="sf-pagehelp-hdr">
    <h3>Page Help</h3>
    <div class="sf-pagehelp-subtext">Quick answers for the current page.</div>
    <div class="sf-pagehelp-wrap">
    <div class="sf-pagehelp-toggle"></div>

    I think i'm having issues because the code will always be in the source so what i'm trying now will never be false...

                //if help is open close it.
                if (browser.Find.ById("sf-pagehelp") != null)
                else if (browser.Find.ByXPath("/html/body/div[3]/div/div[4]/div/span/a/span/span/input") != null)

    any help is appreciated.

  2. Jonas
    Jonas avatar
    20 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    Hello Felix,

    There is a few thing in the Find.Strategy that you can use depending on what will happen if the element is not found.
    I don't know if this is what you are looking for?

    window.Find.Strategy = FindStrategy.AlwaysWaitForElementsVisible;
    window.Find.Strategy = FindStrategy.WhenNotVisibleReturnElementProxy;
    window.Find.Strategy = FindStrategy.WhenNotVisibleReturnNull;
    window.Find.Strategy = FindStrategy.WhenNotVisibleThrowException;

    Best Regards
  3. Anthony
    Anthony avatar
    19 posts

    Posted 19 Jun 2012 Link to this post

    Hello Felix,

    I crafted a test against that successfully implements your solution. If you clear cookies and navigate to Bing, there's a gray banner at the bottom that says "Bing brings search and people together." The containing <div> is:

    <div id="bnp.nid.9092" style="display: block;">

    Clicking the "X" on that banner causes the containing <div> to change:

    <div id="bnp.nid.9092" style="display: none;">

    That meant it was not seen by Test Studio, so the following code succeeded:

    HtmlDiv parent = Find.ById<HtmlDiv>("bnp.nid.9092");
    if (parent != null)
        HtmlDiv center = parent.Find.ById<HtmlDiv>("hpusCtnr");
        HtmlDiv x = center.Find.ByTagIndex<HtmlDiv>("div", 0);
        Find.ById<HtmlInputText>("sb_form_q").Text = "TELERIK";

    If you require further assistance, please provide a public site with a complete code sample so we can reproduce the issue.

    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top