I'm trying to grab the innerHTML if a popup comes up while doing a task in chrome and then based on the innerHTML either click okay and save or exit. The problem where I am running into is just before the possible pop-up I am in an iframe and need to switch back to the main body. I'm using selenium:
main body (possible pop_up *i think*)
iframe (I am here)
Below is some of the code I have, taken out the non-necessary lines:
Dim sel As Selenium.ChromeDriver
Dim pop as Object
Set sel = New Selenium.ChromeDriver
sel.Get URL
' Switch to iframe
Set iframe = sel.FindElementByTag("iframe", 10000)
sel.SwitchToFrame iframe, 5000
code...
' Where the popups sometimes show up
On Error Resume Next
sel.SwitchToDefaultContent
Set pop = sel.FindElementsByClass("popupText", 2000) *Error Could not locate class=popupText
On error goto 0
I get this error if I turn off on error resume next even if there are popups. Below is the HTML:
<span class="popupText">
<br />
*Text*
<br />
<br />
*Text*
</span>
I've tried a couple of other things: not using switchtodefaultcontent, and using switchtoparenframe and nothing seems to work.
There is also a .SwitchToAlert feature in selenium that is not working either...
strAlert = sel.SwitchToAlert.Text 'Get nothing
sel.SwitchToAlert.Accept 'Does not do anything