Reputation: 9538
I am trying to make the window of the selenium bot activated ... First I declared this line
Dim mainWin As selenium.Window
then after the Get line
.Get "https://www.kuwaitcourts.gov.kw/searchPages/searchCases.jsp"
I put this line that sets the window
Set mainWin = .Window
and before a message box I would like to activate the bot window so I used these lines
mainWin.Activate
MsgBox "Click OK After Entering Captcha", 64
There is no problem at the start of the loop as the bot window is already active but as for the second loop I didn't get the bot window activated Any idea how to overcome this point and make the selenium bot window active when needed to be active
Thanks advanced for help
Upvotes: 0
Views: 1047
Reputation: 84455
Use javascript to return focus? For having window at front
bot.ExecuteScript "window.focus();"
Ways of pausing for input:
Why not use an inputBox (set to number type) to capture entry ? Below is pseudo code (assuming captcha is in an iframe which needs to be switched to.
Dim captchaBox As Object, captcha As Long
.SwitchToFrame (.FindElementById("someId")) '<==some identifier for iframe if present
Set captchaBox = .FindElementByCss("#txtCaptia")
' Accept Number from the user
captcha = Application.InputBox("Please enter 4 digit captcha:", "Captcha", , , , , , 1)
captchaBox.Value = captcha
'.SwitchToDefaultContent ''<back to main if in iframe and is required even after submit.
DoEvents
and loop until desired length:Code
Dim submitButton As Object
Set submitButton = .FindElementsByCss("#cmdSubmit")
Do
DoEvents
Loop Until submitButtons.count = 0
Or
Dim captcha As Object
Set captcha = .FindElementsByCss("#txtCaptcha")
Do
DoEvents
Loop Until len(captcha.value) = 4
Upvotes: 1