<div class="w-btn" ng-click="vm.callbacks.compareAll();" ng-if="vm.folderData.projects.length > 0 && vm.noneSelectedProjects" tabindex="0"><i class="glyphicon glyphicon-transfer btn-icon"></i> Report from all</div>
I need to use Powershell to click that button. There are multiple div's on that page with the class="w-btn" but only one with the ng-click that has Compare all in it.
when that button is clicked it will change another tag on the page which is like the following
<a href="/data/project/export/projects-tasks?projectIds[]=103473&projectIds[]=103474&projectIds[]=106186&projectIds[]=108395&projectIds[]=110653&projectIds[]=110657" target="_self" class="inline-btn pull-right" ng-if="vm.projects.length > 0">
the first button changes that href for the projects as they get added. I have to write this script to click the first button and then use the resultant href as part of a link in my wget
so far I haven't been able to get anything to work
$Link = 'https://url.com/folder/2880'
$html = Invoke-WebRequest -Uri $Link -UseDefaultCredentials
$btnclick = $html.getElementsByTagName("div") | Where-object{$_.Name -like 'ng-click="vm.callbacks.compareAll();"' }
when I then do a write to console to see what $btnclick is I get an error:
Method invocation failed because [Microsoft.PowerShell.Commands.HtmlWebResponseObject] does not contain a method named 'getElementsByTagName'
eventually, I think I would then do like $btnclick.Click() and do another getElement on the href so I can pull the
/data/project/export/projects-tasks?projectIds[]=103473&projectIds[]=103474&projectIds[]=106186&projectIds[]=108395&projectIds[]=110653&projectIds[]=110657
portion out.
Any help getting this done is appreciated. The high-level overview is I need to click an angular js button from a webpage and then extract a piece of a URL to use in a wget from the resulting a href tag.
$html.ParsedHtml.getElementsByTagName('div') |where name -like '…'?Invoke-WebRequest'sMicrosoft.PowerShell.Commands.HtmlWebResponseObjectuses IE to headlessly render the DOM unless you add-UseBasicParsing, and the objects returned do seem to have aclick()method.