PowerWebShot icon indicating copy to clipboard operation
PowerWebShot copied to clipboard

Screenshots failing for me

Open snappyq opened this issue 8 years ago • 4 comments

Downloaded the zip, followed the instructions, and received the following error. The report.html file is generated, but no screenshot. Not sure what I'm missing. Both the exe & dll are in the same directory. End-user error?

PS C:\Users\user\Desktop\PowerWebShot> Invoke-PowerWebShot -URL http://www.google.com New-Object : Exception calling ".ctor" with "2" argument(s): "The file .\PhantomJS.exe does not exist. The driver can be downloaded at http://phantomjs.org/download.html" At C:\Users\user\Desktop\PowerWebShot\PowerWebShot.ps1:93 char:11

  • $driver = New-Object OpenQA.Selenium.PhantomJS.PhantomJSDriver($phant ...
  •       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
    • FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

The property 'Url' cannot be found on this object. Verify that the property exists and can be set. At C:\Users\user\Desktop\PowerWebShot\PowerWebShot.ps1:96 char:1

  • $driver.Url = "about:constant"
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyNotFound
    
    

[*] The output directory 2017-07-11-125101 does not exist. Creating directory 2017-07-11-125101.

Directory: C:\Users\user\Desktop\PowerWebShot

Mode LastWriteTime Length Name


d----- 7/11/2017 12:51 PM 2017-07-11-125101
The property 'Url' cannot be found on this object. Verify that the property exists and can be set. At C:\Users\user\Desktop\PowerWebShot\PowerWebShot.ps1:169 char:9

  •     $driver.Url = $name
    
  •     ~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

You cannot call a method on a null-valued expression. At C:\Users\user\Desktop\PowerWebShot\PowerWebShot.ps1:170 char:9

  •     $driver.Manage().Window.Maximize()
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At C:\Users\user\Desktop\PowerWebShot\PowerWebShot.ps1:178 char:9

  •     $driver.GetScreenshot().SaveAsFile(($OutputPath + "\" + $file ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At C:\Users\user\Desktop\PowerWebShot\PowerWebShot.ps1:185 char:9

  •     $driver.Navigate().Back()
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At C:\Users\user\Desktop\PowerWebShot\PowerWebShot.ps1:273 char:1

  • $driver.Quit()
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
    
    
    

PS C:\Users\user\Desktop\PowerWebShot>

snappyq avatar Jul 11 '17 16:07 snappyq

Having same issue - Anyone manage to resolve.

rrngithub avatar Nov 27 '17 12:11 rrngithub

When I received this error the script was looking for the files in the path C:\Windows\system32.

To fix this I

  1. setup the script and it's files as a module by copy the repo to C:\Program Files\WindowsPowerShell\Modules\.
  2. Then, I edited the PowerWebShot.ps1 script to look for the WebDriver.dll file at C:\Program Files\WindowsPowerShell\Modules\PowerWebShot\WebDriver.dll (line 80) and
  3. I modified the $phantomjspath to be C:\Program Files\WindowsPowerShell\Modules\PowerWebShot (line 92).

aperiooculus avatar Mar 27 '18 16:03 aperiooculus

Hello, If you have Powershell 3 or newer, you can do the following changes: line 80: $SeleniumDriverPath = "$PSScriptRoot\WebDriver.dll" line 92: $phantomjspath = $PSScriptRoot

That has fixed the issue for me.

AlexUhde avatar Nov 28 '18 02:11 AlexUhde

Neither of these methods work for me. Not sure what I'm doing wrong.

barrett092 avatar Mar 17 '22 14:03 barrett092