Quantcast
Channel: SharePoint – SharePoint Rider
Viewing all articles
Browse latest Browse all 55

Call Page button click event using PowerShell

$
0
0

Using the below PowerShell commands we can open a page and trigger the click event written inside the page. I am using ListItemCollectionPosition to run the while based on the ROW Limit configured in the CAML query.

Please customize this as per your requirements.

Add-PSSnapin Microsoft.SharePoint.Powershell
$pageURL = "http://server/sites/rnd/_layouts/15/SPTest/Pages/gridtest.aspx"
$url = "http://server/sites/rnd"
$listName = "List Name";

$web = Get-SPWeb $url
$list = $web.Lists[$listName]

$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spQuery.ViewAttributes = "Scope='Recursive'";
$spQuery.RowLimit = 2
$caml = '<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>'
$spQuery.Query = $caml
$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.navigate($pageURL);

while ($ie.Busy -eq $true)
{
Start-Sleep -Milliseconds 1000;
}

Start-Sleep -Milliseconds 5000;

$doc = $ie.document

$viewmoreCNTRL = $doc.getElementByID("ctrlclick")

Start-Sleep -Milliseconds 5000;

do
{
$listItems = $list.GetItems($spQuery)
$spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition

foreach($item in $listItems)
{
Write-Output ("Item #" + $item.ID.ToString());
}

$viewmoreCNTRL.click()
Start-Sleep -Milliseconds 60000;
}
while ($spQuery.ListItemCollectionPosition -ne $null)

$web.Dispose();

 


Filed under: Powershell

Viewing all articles
Browse latest Browse all 55

Trending Articles