当找不到元素时,驱动程序退出

本文关键字:驱动程序 退出 找不到 元素 | 更新日期: 2023-09-27 18:12:34

我正在Android设备上测试使用c#和Appium的本地应用程序。我试图验证一个元素是否可见。问题是,如果没有找到元素,驱动程序退出测试,我想滑动到页面的末尾,直到找到对象。对象肯定在页面的底部。我曾经使用ScrollTo方法,但它已被弃用。

  public void SWipeUntilelementVisible()
        {
            var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));
           
                bool visible = false;
                int counter = 0;
                while (visible == false)
                {
                    if (counter > 0)
                        _driver.Swipe(1200, 1487, 1200, 732, 0);
                    if (isElementVisible(SendRequirement))
                    {
                        visible = true;
                        Console.WriteLine("Visible");
                        break;
                    }
                }
         }
    
          
        public bool isElementVisible(IWebElement Elementid)
        {
            return SendRequirement.Displayed;
        }
    

编辑这是Visual Studio在找不到对象时打印的日志。

Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.NotImplementedException' in WebDriver.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'NUnit.Core.NUnitException' in nunit.core.dll
The thread 0x8a8 has exited with code 0 (0x0).
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
The thread 0x27d8 has exited with code 0 (0x0).
The thread 0x1fbc has exited with code 0 (0x0).
The thread 0x16cc has exited with code 0 (0x0).
The thread 0x19d0 has exited with code 0 (0x0).
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.InvalidOperationException' in WebDriver.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'NUnit.Core.NUnitException' in nunit.core.dll
The thread 0x1fd8 has exited with code 0 (0x0).
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
The thread 0x2380 has exited with code 0 (0x0).
The thread 0x19fc has exited with code 0 (0x0).
The thread 0x261c has exited with code 0 (0x0).
The thread 0x256c has exited with code 0 (0x0).
The thread 0x26cc has exited with code 0 (0x0).
The program '[8096] te.processhost.managed.exe' has exited with code 0 (0x0).

当找不到元素时,驱动程序退出

似乎问题已经解决了。问题是在64位系统上运行,并试图加载32位的dll。