0

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

2
  • Have you tried using inputbox and setting the result to the appropriate element? Commented Jul 17, 2019 at 16:50
  • Thanks a lot.Can you give me more details please? Commented Jul 17, 2019 at 17:05

1 Answer 1

1

Use javascript to return focus? For having window at front

bot.ExecuteScript "window.focus();"

Ways of pausing for input:

  1. inputbox:

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.

  1. 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
Sign up to request clarification or add additional context in comments.

1 Comment

Comments are not for extended discussion; this conversation has been moved to chat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.