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

Command timeout #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Command timeout #211

wants to merge 2 commits into from

Conversation

ili101
Copy link
Contributor

@ili101 ili101 commented May 12, 2021

Problem

We can set timeouts with:

Set-SeDriverTimeout -TimeoutType AsynchronousJavaScript
Set-SeDriverTimeout -TimeoutType ImplicitWait
Set-SeDriverTimeout -TimeoutType PageLoad

but all timeouts above 60 cannot be used as the driver itself have a timeout of 60 seconds by default.
Error:

Get-SeElement -By Id -Value 'submitb' | Invoke-SeClick

MethodInvocationException: \\scripts.ccccloud.local\PsF\Modules\Selenium\4.0.0\Selenium.psm1:802:25
Line |
 802 |                          $Element.Click() #Mitigating IE driver issue  …
     |                          ~~~~~~~~~~~~~~~~
     | Exception calling "Click" with "0" argument(s): "The HTTP request to the remote WebDriver server for URL
     | http://localhost:59213/session/b3f1057c9a99362878b2e6d93a386e0c/element/fcfd92f4-ddd1-4535-88b9-242b896b3cae/click timed out after 60 seconds."

Solution

I added the following command parameter to allow the user to set the driver timeout:

Start-SeDriver -CommandTimeout <seconds>

Example

Reproducible example if needed. Create files:
Server.psd1

@{
    Server = @{
        Request = @{
            Timeout = 600
        }
    }
}

Pode.ps1 create then run in one terminal.

Import-Module -Name Pode
Import-Module -Name Pode.Web

Start-PodeServer -Threads 3 {
    # listen on localhost:8085
    Add-PodeEndpoint -Address localhost -Port 8085 -Protocol Http

    # enable error logging
    New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging

    Use-PodeWebTemplates -Title Test
    Set-PodeWebHomePage -Layouts (New-PodeWebCard -Name 'OK' -Content (
            New-PodeWebParagraph -Elements @(
                New-PodeWebText -Value 'the "Slow" page sleeps for 70 seconds'
                New-PodeWebLink -Value 'link' -Source '/pages/Slow' -id 'slow-link'
            )))
    Add-PodeWebPage -Name 'Slow' -ScriptBlock {
        Start-Sleep -Seconds 70
    }
}

Selenium.ps1 create then run in another terminal.

Import-Module -Name Selenium

$Driver = Start-SeDriver -Browser Chrome #-CommandTimeout 80
$Uri = 'http://localhost:8085'
Set-SeUrl -Url $Uri

Measure-Command {
    Get-SeElement -By Id 'slow-link' | Invoke-SeClick
}

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

Successfully merging this pull request may close these issues.

1 participant