Ask a Question

How do I get the Additional Info text from a WebAccessibility test into a file?

cst99003
Contributor

How do I get the Additional Info text from a WebAccessibility test into a file?

How do I get the Additional Info text from a WebAccessibility test into a file?

8 REPLIES 8
NisHera
Valued Contributor

Could you please describe more about your situation .. 

karkadil
Valued Contributor

You need to create event handler for OnLogError event, inside it use LogParams.AdditionalText property to get the text you need.

You can use aqFile.WriteToTextFile to write the text to the file.

This appear to work as expected but now every ERROR that is triggered hits this EVENT.

 

How do I get the EVENT to only work with this function?

 

 

or

 

Is there a different way to get the "Additional Info" text from the Accessibility Tests?

karkadil
Valued Contributor

How do I get the EVENT to only work with this function?

You can verify the LogParams.MessageText property inside your OnLogError event handler (it is the text from the log). If it contains "Web accessibility" (just double check the string, I'm not sure the text is exact the same), then add the AdditionalInfo to the file. You can use aqString.Find method, for instance, to check the substring presence.

I am sorry but I do not think I am being clear on my question.

What I really need to do is get the text from the Additional Info tab in the ERROR results set.

A previous answer stated I could create an EVENT, which I have, and it is listed below but the problem is that the EVENT triggers EVERY time "any" ERROR is raised and I do not want that to happen.  So what I would like to get is the Additional Info either through an event that is only called when I state it to be called or a different way to get the Additional Info.

I hope this is more clear.

 

 

Unless your post stated to allow the EVENT to trigger and wrap it with an "If" statement for WebAccessibility. I could easily do this but it seems odd that there is not better control of the EVENTs

 


Suggestions or Comments?


Thank you

Andrew

 
function EventControl1_OnLogError(Sender, LogParams)
{

    var sFolder = "M:\\MyFiles\\";
    var aString = LogParams.MessageText;
    var aSubString = "\"";
    var ResFirst = aqString.Find(aString, aSubString);
    var ResLast = aqString.FindLast(aString, aSubString);

    if ( ResFirst != -1 ) {
        str = aqString.SubString(aString, ResLast, aqString.GetLength(aString) );
        aString = aqString.Replace(aString, str, "");
        str = aqString.SubString(aString, 0, ResFirst+1);
        aString = aqString.Replace(aString, str, "");
    }

    var sFile = sFolder + aString + aqConvert.DateTimeToFormatStr(aqDateTime.Today(), "_%Y-%m-%d") + ".txt";

    if (!aqFileSystem.Exists(sFolder)){
        aqFileSystem.CreateFolder(sFolder);
    }

    if (aqFile.Exists(sFile))
    {
        aqFileSystem.DeleteFile(sFile);
        Log.Message("The file was created and the specified text is written to it successfully.");
    }

    aqFile.Create(sFile);
    aqFile.WriteToTextFile(sFile, LogParams.AdditionalText, aqFile.ctUTF8);
}

karkadil
Valued Contributor

Unless your post stated to allow the EVENT to trigger and wrap it with an "If" statement for WebAccessibility.

This was exactly my point: to verify whether error message is posted by WebAccessibility Checkpoint and send additional text of the error to the text file in this case.

 

I have never used WebAccessibility checkpoint, but when I decided to answer your question I made a simple investigation and found out that this looks like the simplest solution, since there is no specific event handler for WebAccessibility Checkpoint. During this investigation I have also found that for some reason if checkpoint fails, than even OnLogCheckpoint doesn't trigger, that's why I suggested using OnLogError.

 

BTW, you can ask Smartbear to add your suggestion to their database and after a while it will be implemented (though nobody can predict when exactly). Just note, that there are many customers and a lot of them have their vision of how the product should work, however it is not always reachable. That's what we are doing here on the forum: helping others finding solutions for their problems. Sometimes they are easy and obvious, sometimes they are workarounds 🙂

 

 

Thank you.

 

I will use the technique (EventControl1_OnLogError) that was suggested and wrap an "if" around it so to only use the code when the Additional Text is needed.

 

Again Thank you

 

Andrew

 

karkadil
Valued Contributor

If you find a better solution - please let us know here 🙂

cancel
Showing results for 
Search instead for 
Did you mean: