找不到元素时驱动程序退出
driver quits when element was not found
我正在 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。
我正在 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。