-MAC 10.12.4
-simulator iphone 6 ios 9
-要实现模拟器 IPhone 调用 Safari 访问某个 URL
-Appium 的 inspector 能把模拟器调出来,Safari 也打开了,但是执行我 c# 的脚本不行,没弄过 C#,代码也没觉得有错,帮忙给看下
错误信息如下
*OpenQA.Selenium.WebDriverException : Unexpected error. System.Net.WebException: The request timed out
at OpenQA.Selenium.Appium.Service.AppiumCommandExecutor.Execute (OpenQA.Selenium.Remote.Command commandToExecute) [0x0005e] in <9b3ceeffa60d410090f33f3b9ea8ebde>:0
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters) [0x00014] in <06ffb9afaa3d4f078661c70468086ad4>:0 *

``using NUnit.Framework;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Appium.iOS;
using System;

namespace FirstDemo
{
[TestFixture]
public class IOSDevice
{
//public IOSDriver driver;
public RemoteWebDriver driver;

//[SetUp]
//public void Class1()
//{
// //Setting Capabilities
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.SetCapability("platformName", "iOS");
// capabilities.SetCapability("platformVersion", "9.0");
// // capabilities.SetCapability("platform", "Mac");
// capabilities.SetCapability("deviceName", "iphone 6s Plus");
// capabilities.SetCapability(CapabilityType.BrowserName, "safari");
// // capabilities.SetCapability("udid", "0b06c4beb1fc32c1be0c356e77601c09120b70c3");
// // capabilities.SetCapability("bundleId", "com.safariLauncher.safariLauncher");
// // capabilities.SetCapability("app", "Safari");
// //Connecting to Appium Server
// driver = new IOSDriver(new Uri("http://172.0.0.1:4723/wd/hub"), capabilities);
//}

[Test]
public void VerifyMenuDevice()
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("platformName", "iOS");
capabilities.SetCapability("platformVersion", "9.0");
// capabilities.SetCapability("platform", "Mac");
capabilities.SetCapability("deviceName", "iphone 6");
capabilities.SetCapability(CapabilityType.BrowserName, "safari");
// capabilities.SetCapability("udid", "0b06c4beb1fc32c1be0c356e77601c09120b70c3");
// capabilities.SetCapability("bundleId", "com.safariLauncher.safariLauncher");
// capabilities.SetCapability("app", "Safari");
//Connecting to Appium Server
driver = new RemoteWebDriver(new Uri("http://172.0.0.1:4723/wd/hub"), capabilities);
//Test to enter loginname & Password on login page
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl("https://myvuapp.u.cu.local");
// wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//UIAButton[1]")));
// driver.FindElement(By.XPath("//UIATextField[1]")).SendKeys("username");
//driver.FindElement(By.XPath("//UIASecureTextField[1]")).SendKeys("password");
//driver.FindElement(By.XPath("//UIAButton[1]")).Click();
}

//[TearDown]
//public void End()
//{
// driver.Quit();
//}
}
}``


↙↙↙阅读原文可查看相关链接,并与作者交流