【问题标题】:Why are methods missing from this object?为什么这个对象缺少方法?
【发布时间】:2022-01-14 19:19:52
【问题描述】:

有一个我以前从未见过的非常奇怪的问题。我正在关注如何使用 Selenium 和 ChromeDriver 进行脚本浏览的教程。将 WebDriver.dll 和 chromedriver.exe 加载到我的工作目录后,我运行它

Add-Type -Path "$($WorkingDir.FullName)\WebDriver.dll"

$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver

当我在对象上运行GetType() 时,它会显示

IsPublic IsSerial Name             BaseType
-------- -------- ----             --------
True     False    ChromeDriver     OpenQA.Selenium.Chromium.ChromiumDriver

但是,当我尝试访问这些方法时,我只能得到这些

PS C:\repo\> $ChromeDriver.
ApplicationCache                ApplicationCache                ClearNetworkConditions          GetType
Capabilities                    Close                           LaunchApp
CommandExecutor                 CloseDevToolsSession            Manage
CurrentWindowHandle             Dispose                         Navigate
FileDetector                    Equals                          PerformActions
HasActiveDevToolsSession        ExecuteAsyncScript              Print
HasApplicationCache             ExecuteCdpCommand               Quit
HasLocationContext              ExecuteChromeCommand            RegisterCustomDriverCommand
HasWebStorage                   ExecuteChromeCommandWithResult  RegisterCustomDriverCommands
IsActionExecutor                ExecuteCustomDriverCommand      ResetInputState
LocationContext                 ExecuteScript                   SelectCastSink
NetworkConditions               FindElement                     SetPermission
PageSource                      FindElements                    StartTabMirroring
SessionId                       GetCastIssueMessage             StopCasting
Title                           GetCastSinks                    SwitchTo
Url                             GetDevToolsSession              ToString
WebStorage                      GetHashCode
WindowHandles                   GetScreenshot

我缺少很多方法,比如这些

FindElement(By) 
FindElementByClassName
FindElementById
FindElementByLinkText
FindElementByName
FindElementByPartialLinkText
FindElementByTagName
FindElementByXPath

提前致谢

编辑

我的系统遇到了一些其他问题,并且一直想重建它,所以我这样做了,我也遇到了同样的问题。

【问题讨论】:

    标签: .net-assembly assemblies


    【解决方案1】:

    事实证明这些方法已被弃用并最终被删除。我使用的示例是最近的,所以我对此感到惊讶。

    https://groups.google.com/g/selenium-users/c/7OF9lMjoRgI/m/45HMvlhmCQAJ

    他们还发布了旧版本的文档,其中仍然列出了缺失的方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-16
      • 1970-01-01
      相关资源
      最近更新 更多