解码时发现无效数据-这是什么意思?

时间:2019-09-09 10:16:13

标签: vb.net selenium selenium-webdriver request selenium-firefoxdriver

我有一个基本功能,可以将Selenium.Firefox驱动程序连接到网站,并且在运行时以前加载的扩展用于注入一些请求标头。在此行

Dim driver As FirefoxDriver = New FirefoxDriver(firefoxOptions)

.. it“死亡”并输出以下错误:

{"Found invalid data while decoding."}

enter image description here

代码如下:

 Public Shared Function WebRequestQlik()
    Try
        Dim appPath As String = System.AppDomain.CurrentDomain.BaseDirectory
        Dim geckodir = Path.GetDirectoryName(appPath)
        Dim profile As FirefoxProfile = New FirefoxProfile()
        Try
            profile.AddExtension(appPath & "modify_headers.xpi")
        Catch e As Exception
        End Try
        profile.SetPreference("modifyheaders.headers.count", 2)
        profile.SetPreference("modifyheaders.headers.action0", "Add")
        profile.SetPreference("modifyheaders.headers.name0", "hdr-user")
        profile.SetPreference("modifyheaders.headers.value0", "SENSE4\catalin")
        profile.SetPreference("modifyheaders.headers.enabled0", True)
        profile.SetPreference("modifyheaders.headers.action1", "Add")
        profile.SetPreference("modifyheaders.headers.name1", "X-Qlik-xrfkey")
        profile.SetPreference("modifyheaders.headers.value1", "123456789ABCDEFG")
        profile.SetPreference("modifyheaders.headers.enabled1", True)
        profile.SetPreference("modifyheaders.config.active", True)
        profile.SetPreference("modifyheaders.config.alwaysOn", True)
        Dim service As FirefoxDriverService = FirefoxDriverService.CreateDefaultService
        Dim firefoxOptions As FirefoxOptions = New OpenQA.Selenium.Firefox.FirefoxOptions()
        firefoxOptions.AddArgument("headless")
        service.HideCommandPromptWindow = True
        firefoxOptions.Profile() = profile
        firefoxOptions.PlatformName = OpenQA.Selenium.Platform.CurrentPlatform.ToString
        Dim driver As FirefoxDriver = New FirefoxDriver(firefoxOptions)
        driver.Navigate().GoToUrl("https://bla.blabla.ro/hdr/single/?appid=82c4ae27-e76f-4d07-9c60-d07be5a6891b&obj=Ydsxt&opt=nointeraction&select=clearall")
        Dim wait As WebDriverWait = New WebDriverWait(driver, TimeSpan.FromSeconds(20))
        Try
            wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("qv-object-content-container")))
        Catch ex As Exception
            Dim ScreenshotErr As Screenshot = CType(driver, ITakesScreenshot).GetScreenshot
            ScreenshotErr.SaveAsFile("C:\Users\blabla\source\repos\blabla\bin\Debug")
            driver.Quit()
            driver.Dispose()
        End Try
    Catch ex As Exception
        Return ex.Message
        Console.WriteLine(ex.ToString())
    End Try
End Function

有人对这种错误有任何想法吗?朝着正确方向的提示是天赐之物。

0 个答案:

没有答案