Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 未知错误:无法通过VB网络使用ChromeDriver Chrome和Selenium聚焦元素_Vb.net_Selenium_Google Chrome_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

Vb.net 未知错误:无法通过VB网络使用ChromeDriver Chrome和Selenium聚焦元素

Vb.net 未知错误:无法通过VB网络使用ChromeDriver Chrome和Selenium聚焦元素,vb.net,selenium,google-chrome,selenium-webdriver,selenium-chromedriver,Vb.net,Selenium,Google Chrome,Selenium Webdriver,Selenium Chromedriver,我面临无法聚焦元素的错误。看起来像 我不知道如何修复它,我就是这么做的,有人能帮我修复它吗 Try Dim options As ChromeOptions = FrmWABot.options options = New ChromeOptions options.AddArguments("user-data-dir=" & Application.StartupPath & "/profile") Clipb

我面临无法聚焦元素的错误。看起来像

我不知道如何修复它,我就是这么做的,有人能帮我修复它吗

Try
        Dim options As ChromeOptions = FrmWABot.options
        options = New ChromeOptions
        options.AddArguments("user-data-dir=" & Application.StartupPath & "/profile")
        Clipboard.SetText(no)
        Dim element As IWebElement = driver.FindElement(By.XPath("//*[@title='Search or start new chat']"))
        Clipboard.SetText(no)
        With element
            .SendKeys(Keys.Control + "v")
            .SendKeys(Keys.Enter)
        End With
        Dim elpesan As IWebElement = driver.FindElement(By.XPath("//*[@id='main']/footer/div[1]/div[2]/div/div[2]"))

        With elpesan
            Clipboard.SetImage(getImage())
            .SendKeys(Keys.Control + "v")
            .SendKeys(Keys.Enter)
        End With

        Dim element1 As IWebElement = driver.FindElement(By.XPath("//*[@id='app']/div[1]/div[1]/div[2]/div[2]/span/div[1]/span/div[1]/div[1]/div[2]/div[1]/span/div[1]/div[2]/div[1]/div[3]/div[2]"))
        element1.Click()
        With element1
            Clipboard.SetText("Happy Birthday...")
            .SendKeys(Keys.Control + "v")
            .SendKeys(Keys.Enter)
        End With
    Catch ex As Exception
        ex.ToString()
    End Try

尝试使用action类而不是常规脚本

Actions action  = new Actions(driver);
action.MoveToElement(element).Build().Perform();
此错误消息

unknown error: cannot focus element (Session info: chrome=77.0.3865.90) (Driver info: chromedriver=2.38.552522
…意味着ChromeDriver无法专注于网络浏览器Chrome浏览器会话

您的主要问题是所使用的二进制文件版本之间的不兼容,如下所示:

  • 您使用的是chromedriver=2.38
  • 的发行说明明确提到以下内容:
支持Chrome v65-67

  • 假设您使用的是chrome=77.0
  • 的发行说明明确提到以下内容:
支持Chrome 77版

因此,ChromeDriver v2.38和Chrome浏览器v77.0之间存在明显的不匹配


解决方案 确保:

  • ChromeDriver已更新到当前级别
  • Chrome更新到当前的Chrome版本77.0级别。(根据)
  • 通过IDE清理项目工作区,并仅使用所需的依赖项重建项目
  • 如果您的基本Web客户端版本太旧,请卸载它并安装最新的GA和Web客户端发布版本
  • 重新启动系统
您可以在中找到相关的讨论