SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    method to detect if a javascripted error message is on the screen?

    I'm testing a web app, which has a page where a user can select one of two radio buttons, and either fill in a text field to go with the first or select from an HtmlListBox for the other. There is javascript in the source for the page, so that if you click "Done" and have left your textfield empty, or entered non-permitted characters for the textfield, or whatever -- simple error checking before accetpting the user's choice -- the javascript puts up an error message in the user's face telling what's wrong. So in trying to write a SilkTest script to test it, I first tried the Exists() method, as in

    Verify(ErrorMessage_1.Exists(), TRUE)

    I coded my testcase so that it tested for all 5 at once, hoping that that would show me that my idea worked -- if it threw exceptions for all but the one that appeared, I had a workable test. But I found that all 5 of the possible messages apparently are seen by Silk as "existing".

    Then I tried IsVisible() as in

    Verify(ErrorMessage_1.IsVisible())

    Somehow Silk takes that method and correctly knows when #1 is the message that's showing, and #2, but for all 3 of the others it apparently thinks that #2 is visible, and reports that to my log.

    I've watched the entire series run through twice, and carefully noted that, as it stepped through each one, each step that the script took was correctl, and the correct error message came up for each of the 5 possible errors.

    Is there any other method I could try for this, or does anyone have an idea of what could be wrong?

    Each one ends with Browser.Close(), so each one runs through independently, as far as I know. I've tried varying the order of the testcases. I've run them one at a time. All the same result.

    ------------------

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: method to detect if a javascripted error message is on the screen?

    Can you provide snippets of your .inc files where ErrorMessage_1, ErrorMessage_2, etc. are defined? Basically the first 3 or 4 lines of each declaration (thru the "tag") will help determine if you simply have a "uniqueness" problem.

    ------------------

  3. #3
    Senior Member
    Join Date
    Jan 2002
    Location
    Des Moines, Iowa
    Posts
    289
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: method to detect if a javascripted error message is on the screen?

    Does the error message come up where you can get the text off of the error message?

    If so just compare the expected text to the actual text.

    You can do that in a verify statement like this:

    of course the variable and object names have been changed to protect the innocent. ~

    ------------------


    [This message has been edited by blacst (edited 09-04-2002).]

  4. #4
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: method to detect if a javascripted error message is on the screen?

    Brent -

    [-] HtmlText PleaseMakeYourOwnPage
    [ ] tag "#5"
    [-] HtmlText PleaseEnterAName
    [ ] tag "#6"
    [-] HtmlText PleaseSelectAPreMadePage
    [ ] tag "#4"
    [-] HtmlText PageNamesCanOnlyContain
    [ ] tag "#2"
    [-] HtmlText SelectedPageAlreadyExists
    [ ] tag "#3"

    I looked at the source code for the page and all 5 are found in there

    <TR>
    <TD ALIGN="CENTER" ID="addTabDiv" STYLE="visibility:hidden;display:none;" COLSPAN=2>
    <SPAN CLASS="errorBoxPage">Please make your own Page or select a pre-made Page.</span>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER" ID="tabNameDiv" STYLE="visibility:hidden;display:none;" COLSPAN=2>
    <SPAN CLASS="errorBoxPage">Please enter a name for your new page.</span>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER" ID="preMadeDiv" STYLE="visibility:hidden;display:none;" COLSPAN=2>
    <SPAN CLASS="errorBoxPage">Please select a pre-made page.</span>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER" ID="invalidCharDiv" STYLE="visibility:hidden;display:none;" COLSPAN=2>
    <SPAN CLASS="errorBoxPage">Page names can only contain letters and/or numbers.</span>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER" ID="dupTabNameDiv" STYLE="visibility:hidden;display:none;" COLSPAN=2>
    <SPAN CLASS="errorBoxPage"><SPAN ID="duplicateNameSpan1">Selected Page</SPAN>already exists in your account.</span>
    </TD>
    </TR>

    And the code appears the same whether I "View Source" when a message is showing or not. So, how the visibility is happening or not, I don't know. I'm fairly new at this stuff. Just out of school, first job. When I saw the terms "visibility" and "hidden" I looked in the manual for methods and found IsVisible.

    Looks like the tags are unique?

    blacst - I gotta run. I'm late to pick up my wife. I'll try your idea tomorrow

    Thanks

    F


    ------------------

  5. #5
    Senior Member
    Join Date
    Jul 2000
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: method to detect if a javascripted error message is on the screen?

    Hmmm ... interesting ...

    "blacst" was heading down the same path I was, but from a different direction ...

    From what you've provided, am I correct in assuming that the message does NOT appear in a popup dialog (a MessageBox), but in fact appears as a "hidden / visible text line" right on the browser page? That explains why IsVisible() works "better" than Exists(). Every message effectively "exists", it's just a matter of visibility.

    Based on what you've sent, I'm also guessing that you use index numbers exclusively for the object tags? Have you tried using the caption? I've found a lot of "ambiguity" when using index numbers ... and almost always go with either the caption or the "$" identifiers.

    If you've already tried the captions, then the other thought I have (for purposes of verifying that this *should* work) would be to try the long form for the object:

    BrowserPage.HtmlText("Please Make Your Own").IsVisible()

    One other thing you might try is:

    BrowserPage.ExecLine ( 'alert "your HTML object name".style.visiblity' ) )

    This will display an alert dialog with either "TRUE" or "FALSE" depending on whether the object you specified is visible (according to it's HTML / DOM style setting).

    Gads, now we're getting kludgey ...

    ------------------

    [This message has been edited by Brent Rolland (edited 09-04-2002).]

  6. #6
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: method to detect if a javascripted error message is on the screen?

    Brent -

    Yes -- the text appears on the page, not as a MessageBox (I mean like a VB MessageBox). When it comes, a small space opens above the textfield and listbox area and a gentle yellow box appears with the text of the message. I had the same reasoning about Exists vs IsVisible.

    And yes I use index tags generally. When I was first taught Silk by the intern who preceded me and who left two weeks after I started, I was told that multiple tags often lead to problems and indexes are generally the best choice for a single tag option, at least in our product, and don't generally think of that when I get a puzzling behavior. Good reminder, I'll play with it tomorrow. The other ideas, too. I take it that the

    BrowserPage.HtmlText("Please Make Your Own").IsVisible()

    line simply returns TRUE if there is an instance of that text showing somewhere in the window?

    Those are new tricks for me.

    Thanks

    F

    ------------------

  7. #7
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: method to detect if a javascripted error message is on the screen?

    Yes multitagging can lead to improper identification. It is a good practice to use a single tag, and I prefer either the caption, or the windowID. Indexing is particularly problematic if the items on the page move and the index changes.

    If there are problems with an object being identified, I will multitag by hand, but not by default.

    I'd recommend doing as mentioned above and grabing the message text itself and comparing it with expected text.


    ------------------

  8. #8
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: method to detect if a javascripted error message is on the screen?

    Thanks. i'll try tomorrow. Down all day - a power failure knocked out the company's network. Couldn't even get to the Silk license server!!

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:38 AM.

Copyright BetaSoft Inc.