Writing to the Log

12 posts, 1 answers
  1. Nigel
    Nigel avatar
    53 posts
    Member since:
    Jan 2012

    Posted 30 Jan 2012 Link to this post

    Hi,
    I am a newcomer to Test Studio, still in the trial period.  I hope I am posting to the write forum. 

    I need to write a debug line to the log so I can trace failures.

    I have an Excel data source with multiple columns and multiple rows.  My scripts parse the data fine, and tell me there has been a failure, but the log does not make it easy to see in which iteration the failure occurred.

    One of the columns in my data is a row counter.  How can I read the value in this counter (the column name is Iteration)?  I assumed I could simply bind the value to a comment with $(Iteration), but this does not appear possible.

    I tried putting a VB "log.writeline($(Iteration))" expression in the code-behind window but this just failed (I am far from an expert in VB).

    Any advice would be appreciated.

    Thanks,
    Nigel.
  2. Answer
    Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 31 Jan 2012 Link to this post

    Hi Nigel,
    the correct VB code is as follows:
    Log.WriteLine("Value from iteration column is: " + DirectCast(Data("iteration"), [String]))

    Check out the following article:
    http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/attach-columns-to-input-values-in-code.aspx

    Let me know if you require additional assistance in order to get this to work.

    Greetings,
    Stoich
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Nigel
    Nigel avatar
    53 posts
    Member since:
    Jan 2012

    Posted 31 Jan 2012 Link to this post

    Wonderful!  It's always easy when you know how, isn't it?  Many thanks for your excellent assistance, Stoich!  :)
  4. srikanth
    srikanth avatar
    2 posts
    Member since:
    Mar 2016

    Posted 17 May in reply to Stoich Link to this post

    Can you also post the code in C# for writing Error log.
  5. Aaron
    Aaron avatar
    31 posts
    Member since:
    May 2016

    Posted 17 May in reply to srikanth Link to this post

    Log.WriteLine("Insert a line into the log.");

    It is basically the same as the VB code, except you need to add the semicolon onto the end of the line.

  6. srikanth
    srikanth avatar
    2 posts
    Member since:
    Mar 2016

    Posted 17 May in reply to Aaron Link to this post

    Got it.

    Thanks Aaron

  7. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 19 May Link to this post

    Hello,

    @Aaron, thank you for sharing your knowledge with the community. We appreciate it.

    @Srikanth, If you need further assistance please let us know.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  8. Viral
    Viral avatar
    7 posts
    Member since:
    Jan 2015

    Posted 28 Aug in reply to Stoich Link to this post

    Hi,

    Is there anyway to disable log writing of specific test case?

    Scenario: We are using one test case (Test-A) as a step in almost all of our test cases repetitively. Test execution writes a lot of lines log of Test-A repetitively in log file and it makes it hard to read tes log file. 

    I was wondering if there is a way to disable log writing for specific test case or test step?

  9. Viral
    Viral avatar
    7 posts
    Member since:
    Jan 2015

    Posted 28 Aug in reply to Viral Link to this post

    Sample of logs of test case looks like below.

    >>> Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log starts:

    Overall Result: Pass
    ------------------------------------------------------------
    '8/29/2016 2:08:44 PM' - Detected custom code in test. Locating test assembly: TestAutomation.dll.
    '8/29/2016 2:08:44 PM' - Assembly Found: C:\QualityAssurance\AutomatedTests\bin\TestAutomation.dll
    '8/29/2016 2:08:44 PM' - Loading code class: 'TestAutomation.Helpers_TestSteps_Wait_WaitForBrowserReady'.
    ------------------------------------------------------------
    ------------------------------------------------------------
    '8/29/2016 2:08:44 PM' - Enabling Html Popup Tracker. Test expecting Popups.
    '8/29/2016 2:08:44 PM' - Using 'InternetExplorer' version '11.0' as default browser. 
    '8/29/2016 2:08:44 PM' - Using 'https://example.com/' as base url.
    '8/29/2016 2:08:45 PM' - 'Pass' : 1. Waiting
    ------------------------------------------------------------
    '8/29/2016 2:08:45 PM' - Overall Result: Pass
    '8/29/2016 2:08:45 PM' - Duration: [0 min: 1 sec: 611 msec]
    ------------------------------------------------------------

    <<< Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log ends.

  10. Viral
    Viral avatar
    7 posts
    Member since:
    Jan 2015

    Posted 28 Aug in reply to Viral Link to this post

    Sample of log records look like as below:

    >>> Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log starts:

    Overall Result: Pass
    ------------------------------------------------------------
    '8/29/2016 2:08:44 PM' - Detected custom code in test. Locating test assembly: TestAutomation.dll.
    '8/29/2016 2:08:44 PM' - Assembly Found: C:\QualityAssurance\AutomatedTests\bin\TestAutomation.dll
    '8/29/2016 2:08:44 PM' - Loading code class: 'TestAutomation.Helpers_TestSteps_Wait_WaitForBrowserReady'.
    ------------------------------------------------------------
    ------------------------------------------------------------
    '8/29/2016 2:08:44 PM' - Enabling Html Popup Tracker. Test expecting Popups.
    '8/29/2016 2:08:44 PM' - Using 'InternetExplorer' version '11.0' as default browser. 
    '8/29/2016 2:08:44 PM' - Using 'https://example.com/' as base url.
    '8/29/2016 2:08:45 PM' - 'Pass' : 1. Waiting
    ------------------------------------------------------------
    '8/29/2016 2:08:45 PM' - Overall Result: Pass
    '8/29/2016 2:08:45 PM' - Duration: [0 min: 1 sec: 611 msec]
    ------------------------------------------------------------

    <<< Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log ends.
    <<< Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log ends.

  11. Viral
    Viral avatar
    7 posts
    Member since:
    Jan 2015

    Posted 28 Aug in reply to Viral Link to this post

    Sample of log records look like as below. I want to disable these lines being logged.

     

    >>> Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log starts:<br><br>Overall Result: Pass<br>------------------------------------------------------------<br>'8/29/2016 2:08:44 PM' - Detected custom code in test. Locating test assembly: TestAutomation.dll.<br>'8/29/2016 2:08:44 PM' - Assembly Found: C:\QualityAssurance\AutomatedTests\bin\TestAutomation.dll<br>'8/29/2016 2:08:44 PM' - Loading code class: 'TestAutomation.Helpers_TestSteps_Wait_WaitForBrowserReady'.<br>------------------------------------------------------------<br>------------------------------------------------------------<br>'8/29/2016 2:08:44 PM' - Enabling Html Popup Tracker. Test expecting Popups.<br>'8/29/2016 2:08:44 PM' - Using 'InternetExplorer' version '11.0' as default browser. <br>'8/29/2016 2:08:44 PM' - Using 'https://example.com/' as base url.<br>'8/29/2016 2:08:45 PM' - 'Pass' : 1. Waiting<br>------------------------------------------------------------<br>'8/29/2016 2:08:45 PM' - Overall Result: Pass<br>'8/29/2016 2:08:45 PM' - Duration: [0 min: 1 sec: 611 msec]<br>------------------------------------------------------------<br><br><<< Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log ends.<br><<< Test-as-Step 'Helpers\TestSteps\Wait\Helpers_TestSteps_Wait_WaitForBrowserReady.tstest' log ends.

  12. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    251 posts

    Posted 31 Aug Link to this post

    Hi Viral,

    This is the standard log that is being created within test execution and you could only add lines to it but you could create an external log file. Please let me know if you would need further assistance. 

    Regards,
    Elena Tsvetkova
    Telerik by Progress
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top