驱动程序在未找到元素时退出

时间:2016-10-10 10:25:47

标签: c# android selenium appium

我在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).




1 个答案:

答案 0 :(得分:0)

似乎解决了这个问题。问题是在64位系统上运行并尝试加载32位dll。