Vb.net 无法单击selenium chromedriver

Vb.net 无法单击selenium chromedriver,vb.net,selenium,selenium-chromedriver,Vb.net,Selenium,Selenium Chromedriver,我无法通过cssselector或甚至xpath执行单击操作,甚至无法将密钥发送到空格或回车 我认为youtube正在阻止它。谢谢你的帮助 我的代码: Public Function OpenVideo(video As String) Try Form1.UpdateStatus("Opening video ...") If (Driver Is Nothing) Then Return "&quo

我无法通过
cssselector
或甚至
xpath
执行单击操作,甚至无法将密钥发送到空格或回车

我认为youtube正在阻止它。谢谢你的帮助

我的代码:

Public Function OpenVideo(video As String)
    Try
        Form1.UpdateStatus("Opening video ...")
        If (Driver Is Nothing) Then
            Return ""
        End If
        _Status = True
        Driver.Navigate().GoToUrl(video)
        'Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5)
        'TESTING

        ' Driver.SwitchTo.Frame(0)
        Dim element = Driver.FindElementByCssSelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > span:nth-child(2) > button[aria-label='Play (k)'")
        element.click()


        ViewsByVideo = 0
        d = DateTime.Now
        If (clockTimer Is Nothing) Then
            Dim autoEvent As New AutoResetEvent(False)
            clockTimer = New Timer(AddressOf ClockFunction, autoEvent, 0, 1000)
        Else
            clockTimer.Change(0, 1000)
        End If
        IsPlaying = True
    Catch ex As Exception
        LogManager.AddLog(ex.Message)
    End Try
    _Status = False
End Function
如果可能的话我不想单击元素或按钮,只需“点击空格”,这样我就可以确保它总是按play,因为空格和play是一样的

谢谢

在最后一步尝试使用
css选择器
。 如果这不起作用,那么可能是页面存在DOM问题,或者自动脚本被阻止