Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Problem with ie.Document.getElementById - "You cannot call a method on a null-valued expression."

$
0
0

Hi,

 

I've built the following script that supposed to add text in the Google search box:

 

$url = "https://www.google.com/" 

$search_input="something" 

$ie = New-Object -com internetexplorer.application; 

$ie.visible = $true; 

$ie.navigate($url); 

while ($ie.Busy -eq $true) 

    Start-Sleep -Milliseconds 1000; 

$ie.Document.getElementById("lst-ib").value = $search_input

 

 

I'm getting the following errors:

 

PS C:\Users\user\Desktop> .\Serach_In_Google.ps1

You cannot call a method on a null-valued expression.

At C:\Users\user\Desktop\Serach_In_Google.ps1:10 char:28

+ $ie.Document.getElementById <<<< ("lst-ib").value = $search_input

+ CategoryInfo          : InvalidOperation: (getElementById:String) [], RuntimeException

+ FullyQualifiedErrorId : InvokeMethodOnNull

 

Thanks


Viewing all articles
Browse latest Browse all 6937

Trending Articles