我正在尝试使用 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
我的代码如下:
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;
private static WebElement CalculatorResult = null;
@BeforeClass
public static void setup() {
try {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app", "C:\\Windows\\System32\\calc.exe");
CalculatorSession = new IOSDriver(new URL("http://127.0.0.1:4723"), capabilities);
CalculatorSession.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
CalculatorSession.findElementByName("Clear").click();
CalculatorSession.findElementByName("Seven").click();
CalculatorResult = CalculatorSession.findElementByName("Display is 7 ");
Assert.assertNotNull(CalculatorResult);
}catch(Exception e){
e.printStackTrace();
} finally {
}
}
}
我的开发环境
如果有人可以帮助我解决此问题,我将非常高兴。
提前致谢。
最佳答案
经过长期研究,我找到了上述问题的答案。我们可以使用两种方法解决此问题。
CalculatorSession = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
CalculatorSession = new IOSDriver(new URL("http://127.0.0.1:4723"), capabilities);