Chrome Selenium web sitesi penceresini gizlemek

Katılım
15 Mart 2005
Mesajlar
353
Excel Vers. ve Dili
Microsoft 365 En 64 Bit
Merhaba,

Chrome Selenium da aşağıdaki kod ile sayfayı gizleyebiliyorum.

Anacak sitede güvenlik kodu sorusu (captcha) mevcut. Bu nedenle aşağıdaki kodu başta yazamıyorum.

Güvenlik sorusu manuel cevaplanıp devam butonuna basıldıktan sonra sayfayı gizleyebilir miyim?

İyi akşamlar.


C#:
URL = "xxxxxxxxxxx.com"
cd.AddArgument "--headless" 
cd.get URL
 

Necdet

Moderatör
Yönetici
Katılım
4 Haziran 2005
Mesajlar
15,180
Excel Vers. ve Dili
Ofis 365 Türkçe
Deneyin, sonucunu bize de söyleyin.
Ben denedim olmadı, belki sizinkisi olabilir :)
 
Katılım
15 Mart 2005
Mesajlar
353
Excel Vers. ve Dili
Microsoft 365 En 64 Bit
Merhaba,

API ile ilgili kodlar aşağıdadır. Deneyeceğim...

C++:
#If VBA7 Then
    Public Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Boolean
    Public Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As LongPtr, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
#Else
    Public Declare Function ShowWindow Lib "USER32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Boolean
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
#End If

    
Sub Test()

    Dim hwnd As Long
    Dim Botwindowtitle As String
    Dim bot As New Selenium.ChromeDriver
    
    bot.Start
    bot.Get "https://www.google.com/"
    Botwindowtitle = bot.Window.Title
    hwnd = GetAllWindowHandles(Botwindowtitle)
    Call ShowWindow(hwnd, 7) 'Show the window minimized (SW_SHOWMINNOACTIVE = 7) http://www.jasinskionline.com/windowsapi/ref/s/showwindow.html   
    
End Sub


Private Function GetAllWindowHandles(partialName As String) As Long
    Dim hwnd As Long, lngRet As Long
    Dim strText As String
    Dim hWndTemp As Long
    hwnd = FindWindowEx(0&, 0&, vbNullString, vbNullString)

    Do While hwnd <> 0
        strText = String$(100, Chr$(0))
        lngRet = GetWindowText(hwnd, strText, 100)

        If InStr(1, strText, partialName, vbTextCompare) > 0 Then
            Debug.Print "Window Handle:" & hwnd & vbNewLine & _
                        "Window title:" & Left$(strText, lngRet) & vbNewLine & _
                        "----------------------"
            hWndTemp = hwnd
            GetAllWindowHandles = hWndTemp
        End If

        '~~> Find next window
        hwnd = FindWindowEx(0&, hwnd, vbNullString, vbNullString)
    Loop
End Function
 
Üst