我正在尝试使用Windows应用程序驱动程序(winAppDriver),appium和java在windows10上运行Windows计算器应用程序的自动测试,如下例所示:https: //github.com/Microsoft/WinAppDriver/tree/master/Samples/Java/CalculatorTest,但是当我开始appium运行测试后得到下面提到的错误:
org.openqa.selenium.UnsupportedCommandException: The URL '/session' did not map to a valid resource
Command duration or timeout: 204 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'LKXXXX', ip: '10.88.68.53', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: io.appium.java_client.ios.IOSDriver
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
import org.junit.*;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.util.concurrent.TimeUnit;
import java.net.URL;
import io.appium.java_client.ios.IOSDriver;
public class CalculatorTest {
private static IOSDriver CalculatorSession = null; …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用winappdriver从WPF项目中的GridView 获取单元格值。
我在这条线上遇到了一个问题:
string name = row.FindElementByName("Name1").Text;
Run Code Online (Sandbox Code Playgroud)
使用给定的搜索参数无法在页面上定位元素。
您能否检查我的以下代码:
<Grid>
<ListView Margin="10" Name="lvUsers" AutomationProperties.AutomationId="lvUsers">
<ListView.View>
<GridView x:Name="ListViewItem" AutomationProperties.AutomationId="ListViewItem">
<GridViewColumn x:Name="Name1" AutomationProperties.Name="Name1" AutomationProperties.AutomationId="Name1" Header="Name" Width="120" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Header="Age" Width="50" DisplayMemberBinding="{Binding Age}" />
<GridViewColumn Header="Mail" Width="150" DisplayMemberBinding="{Binding Mail}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
var listBox = session.FindElementByAccessibilityId("lvUsers");
var comboBoxItems = listBox.FindElementsByClassName("ListViewItem");
foreach (var row in comboBoxItems)
{
string name = row.FindElementByName("Name1").Text;
if (name == "John Doe")
{
findName = true;
break;
}
}
Assert.AreEqual(findName, true);
Run Code Online (Sandbox Code Playgroud) 我有很多测试.有时如果找不到元素,只需点击屏幕的左上角即可.这不会一直发生,但确实发生了.我不确定为什么会这样.在我的setUp方法中,我告诉它单击元素"Maximize"但是如果它找不到该元素我将它放入catch并忽略它.出于某种原因,当它找不到元素时,只需单击屏幕左上角的应用程序会话即可.
有没有人知道为什么会发生这种情况,或者只是硒有时会如何反应
我的代码如下
private string wordId = OfficeVersion.Word();
private string excelId = OfficeVersion.Excel();
private string powerPointId = OfficeVersion.PowerPoint();
private const string AppDriverUrl = "http://127.0.0.1:4723";
public static WindowsDriver<WindowsElement> excelSession;
public static WebDriverWait webDriverWait;
xl.Workbook WB;
public static bool skipTearDown = false;
WindowsElement create;
WindowsElement blankWorkBook;
public static DesiredCapabilities appCapabilities = new DesiredCapabilities();
[TestInitialize]
appCapabilities.SetCapability("app", excelId);
var initialSession = new WindowsDriver<WindowsElement>(new Uri(AppDriverUrl), appCapabilities);
var capabilities = new DesiredCapabilities();
capabilities.SetCapability("app", "Root");
excelSession = new WindowsDriver<WindowsElement>(new Uri(AppDriverUrl), capabilities);
webDriverWait = new WebDriverWait(excelSession, TimeSpan.FromSeconds(10));
CommonMethods.keyCheck(excelSession); …Run Code Online (Sandbox Code Playgroud) 我正在使用带有 WinAppDriver 的 Appium 来控制 WinForms/WPF 应用程序。
我正在寻找一种编程方式来获取已检索元素上可用的属性列表。
我目前的想法是要求 className 并使用它来查找我预先配置的属性的静态字典。
var element = driver.FindElementByXPath(xPath);
var properties = element.getProperties(); // Is there something I can call here?
Run Code Online (Sandbox Code Playgroud) 我的简单 WPF 应用程序包含一个复选框。我正在尝试使用 Windwos 应用程序驱动程序自动测试此应用程序。创建会话后,单击复选框。之后我想验证是否选中了复选框。但是复选框对象的类型是 WindowsElement 所以我的代码不能工作。
换句话说:如何在 WinAppDriver 测试中访问这些控件类型?
https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-controltypesoverview
<CheckBox AutomationProperties.AutomationId="CheckBox1"/>
Run Code Online (Sandbox Code Playgroud)
[Test Method]
public void TestMethod1()
{
const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
const string SimpleWPFTestID = @"C:\Users\bla\source\repos\SimpleWPFApp\SimpleWPFApp\bin\Debug\SimpleWPFApp.exe";
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", SimpleWPFTestID);
var session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
WindowsElement CheckBox1 = session.FindElementByAccessibilityId("CheckBox1");
CheckBox1.Click();
Assert.IsTrue(CheckBox1.IsChecked); // this line does not work :-(
}
Run Code Online (Sandbox Code Playgroud) 我有一个如此微不足道的问题,但我很难让我的代码在继续之前正确等待对象。
我为我的驱动程序设置了以下配置
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
Run Code Online (Sandbox Code Playgroud)
我原以为这意味着它会等待至少 60 秒,然后才会抛出与元素识别相关的错误,例如
Message: System.InvalidOperationException : An element could not be located on the page using the given search parameters.
Run Code Online (Sandbox Code Playgroud)
然而,这种情况并非如此。当我尝试调用以下命令时,大约 2 秒后出现错误。
WindowsElement btn = session.FindElementByXPath("//Button[@Name='NEXT']");
btn.Click();
Run Code Online (Sandbox Code Playgroud)
该错误是在我刚刚定义按钮属性的行上引发的,而不是在实际的 Click() 方法上引发的。我没有正确传递元素属性吗?为什么按钮的实例化也会对其进行搜索?
我一直在努力使WinAppDriver正常运行。这是使用Selenium来测试窗口应用程序的一种方法。
按照下面的说明,我已经安装了WinAppDriver。运行它时,它应该在命令窗口中保持打开状态。然而,矿山并没有保持开放状态,这就是问题所在。
我的问题是,当我导航到“ C:\ Program Files(x86)\ Windows Application Driver”并从中运行(打开)时,为什么WinAppDriver立即关闭?我尝试右键单击并选择“以管理员身份运行”,并且发生了同样的事情。
我已经与IT支持人员进行了交谈,他们检查了防病毒程序是否能够阻止它。
我正在观看的演示视频在此处,并且WinAppDriver从此处安装,并且需要运行。运行时,它会打开一个CMD窗口,其中显示“ Wi8ndow应用程序驱动程序在以下位置监听请求:http : //127.0.0.1 :4723/ 按ENTER退出。”。您可以在大约5:30的视频中看到它们启动WinAppDriver.exe,并且CMD窗口打开并保持打开状态。我的矿山立即关闭的可能原因是什么?
安装和运行Windows应用程序驱动程序
1.从https://github.com/Microsoft/WinAppDriver/releases下载Windows应用程序驱动程序安装程序
2.在安装了要测试的应用程序的Windows 10计算机上运行安装程序
3.从安装目录运行WinAppDriver.exe(例如C:\ Program Files(x86)\ Windows Application Driver)
一般来说,对于 Web 应用程序,如果我们想从淹没中选择一个选项,我们使用 SelectElement 方法。
但在 Windows 应用程序中,当我尝试使用 SelectElement 方法时,出现以下错误:
OpenQA.Selenium.Support.UI.UnexpectedTagNameException:元素应该已选择,但是 ControlType.ComboBox
那么对于 Windows 应用程序,如何从 ComboBox 下拉列表中选择一个项目?
我正在 Windows 10 虚拟机上远程完成所有工作(通过 RDP)。每当我登录到服务器时,我都可以看到我的自动化运行良好,但是当我关闭 RDP 连接时,WinAppDriver 找不到桌面应用程序上的元素,因此它停止工作。
我该如何解决?如果我遗漏了什么,请告诉我。
谢谢
使用终端命令在 VS Code 中构建的示例NotepadAndCalculatorTestdotnet build项目会引发以下错误:
C:\Program Files\dotnet\sdk\5.0.401\Microsoft.Common.CurrentVersion.targets(820,5): error : The BaseOutputPath/OutputPath property is not set for project 'NotepadCalculatorTest.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. You may be seeing this message because you are trying to build a project without a solution file,
and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\Users\<username>\VSCode Projects\WinAppDriverTryout\Test\Samples\C#\NotepadAndCalculatorTest\NotepadCalculatorTest.csproj]
Run Code Online (Sandbox Code Playgroud)
或者:
NotepadCalculatorTest.csproj(109,5): error : …Run Code Online (Sandbox Code Playgroud)