Asked by:
Grabbing popup data with Powershell controlled IE?

General discussion
-
Trying to get data from a popup window
browser example:
http://webcache.gmc-uk.org/gmclrmp_enu/start.swe?
search for number 6128571
And click on the links:
This doctor is subject to revalidation
Or
View information for Employers
A popup window shows up.
I fail to grab its content with powershell. Any hints?
$gmctocheck = "6128571"
$ie = New-Object -com "InternetExplorer.Application"
$url = "http://webcache.gmc-uk.org/gmclrmp_enu/start.swe?"
$ie.navigate($url)
while ($ie.ReadyState -ne 4) {start-sleep -milliseconds 20}
while (!($ie.document.title -eq "List of Registered Medical Practitioners `| Doctor Search")) {start-sleep -milliseconds 20}
$ie.document.frames.item(0).document.frames.item(1).document.getElementById("gmcrefnumber").Value = $gmctocheck
$ie.document.frames.item(0).document.frames.item(1).document.getElementById("s_3_1_10_0").Click()
while ($ie.ReadyState -ne 4) {start-sleep -milliseconds 20}
while (!( ($ie.document.title -eq "List of Registered Medical Practitioners `| Doctor Details") -or ($ie.document.title -eq "List of Registered Medical Practitioners `| Search Results") ) ) {start-sleep -milliseconds 20}
if ( $ie.document.title -eq "List of Registered Medical Practitioners `| Doctor Details" ) {
$revalinfo = $null
$revalinfo = $ie.document.frames.item(0).document.frames.item(1).document.getElementById("s_2_1_1_0").innerHTML
$revalinfo
$href1 = $null
$href1 = $ie.document.frames.item(0).document.frames.item(1).document.getElementById("s_2_1_1_0").href
$href1
$ie.document.frames.item(0).document.frames.item(1).document.getElementById("s_2_1_1_0").click()
while ($ie.ReadyState -ne 4) {start-sleep -milliseconds 20}
# HERE CODE TO GRAB POPUP
}else{
#next one
}
$ie.visible = $true
$ie.Quit()
$ie = $null
[GC]::Collect()
<tmui style="top:1px;right:1px;"></tmui>- Changed type Bill_Stewart Wednesday, December 12, 2018 5:11 PM
- Moved by Bill_Stewart Wednesday, December 12, 2018 5:11 PM This is not "debug/fix/rewrite my script for me" forum
Wednesday, August 8, 2018 1:46 PM
All replies
-
Please read the following:
This forum is for scripting questions rather than script requests
-- Bill Stewart [Bill_Stewart]
Wednesday, August 8, 2018 1:50 PM -
$sh = New-Object -ComObject Shell.application $win = $sh.Windows()|where{$_.LocationName -eq 'List of Registered Medical Practitioners | Doctor Search'} $win.Document.documentElement.innerText
\_(ツ)_/
Wednesday, August 8, 2018 2:09 PM -
Thanks for the swift reply jrv
unfortunately this grabs the main window, and not the popup
The popup isn't even visible with $sh.windows()Greetings
PHEC
<tmui style="top:1px;right:1px;"></tmui>
Wednesday, August 8, 2018 3:58 PM -
Thansk for the reply Bill,
It's not a code request.
Just got totally stuck even after googling several hours.
Adding $ie.visible = $true shows me that clicking the popup opens a new blank window, and then a new tab in the original window with the popup content.
Don't know how to get the content from that 2nd tab either, thus still stuck.Surely there must be a smarter way part from going for elaborate sendkeys solutions?
Greetings
PHEC
<tmui style="top:1px;right:1px;"></tmui>
Wednesday, August 8, 2018 4:04 PM -
found a solution that works for me
popup opens new window, which is the last in the aray of windows
# Get array of IE windows
$ObjIE2 = (New-Object -COM "Shell.Application").Windows() | ? { $_.Name -eq "Internet Explorer" }
# get document of the last one (1st has index 0)
$doc2 = $ObjIE2[($ObjIE2.Count - 1)]
#after that the usual stuff#View information for Employers
$RetentionFeeDue = ($doc2.document.body.getElementsByTagName('td'))[5].innertext
#closing
($doc2.document.body.getElementsByTagName('td'))[7].document.links[1].click()
Frankly, didn't know you can connect to already existing object
Thansk for the inspiration to jrv
Cheers
PHEC
<tmui style="top:1px;right:1px;"></tmui>
Wednesday, August 15, 2018 3:29 PM -
BTW, also did a reset of IE settings to defaults, so that may have affected this too.
<tmui style="top:1px;right:1px;"></tmui>
Wednesday, August 15, 2018 3:30 PM