Prevent the driver to allow popups (advertisements)

  • Hello everyone
    I started to deal with selenium and I have this code

    Sub Test()
    Dim bot As New WebDriver
    Dim r As Long
    Dim c As Long
    bot.Start "chrome", ""
    bot.Get "/searchbyname.aspx"
    For r = 1 To Cells(Rows.Count, 1).End(xlUp).Row
    With Sheets(1)
    c = 1
    bot.FindElementById("txt_Epicno").SendKeys (CStr(.Cells(r, 1).Value))
    If bot.FindElementById("lblmsg").Text Like "Your Record is Not Available*" Then
    .Cells(r, c + 1).Value = "Your Record is Not Available Now. For Further Enquiry Please Call 1950."
    .Cells(r, c + 1).Value = bot.FindElementById("lbnameen").Text
    .Cells(r, c + 2).Value = bot.FindElementById("lbparten").Text
    .Cells(r, c + 3).Value = bot.FindElementById("lbserialen").Text
    .Cells(r, c + 4).Value = bot.FindElementById("lbpartnameen").Text
    End If
    End With
    Next r
    End Sub

    Data in column A

    The problem is that when posting a value using sendkeys I found that there are windows opening in new tabs (advertisements) and that make the code fails
    How to prevent those advertisements ..?

Log in to reply

Looks like your connection to Codingislove Forum was lost, please wait while we try to reconnect.