本文整理汇总了C#中OpenQA.Selenium.Remote.DesiredCapabilities.SetCapability方法的典型用法代码示例。如果您正苦于以下问题:C# DesiredCapabilities.SetCapability方法的具体用法?C# DesiredCapabilities.SetCapability怎么用?C# DesiredCapabilities.SetCapability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Remote.DesiredCapabilities
的用法示例。
在下文中一共展示了DesiredCapabilities.SetCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeAll
public void BeforeAll()
{
String TESTDROID_USERNAME = "Testdroid username";
String TESTDROID_PASSWORD = "Testdroid Password";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("device", "Android");
capabilities.SetCapability("deviceName", "Android");
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("testdroid_username", TESTDROID_USERNAME);
capabilities.SetCapability("testdroid_password", TESTDROID_PASSWORD);
capabilities.SetCapability("testdroid_target", "Android");
capabilities.SetCapability("testdroid_project", "C# Appium");
capabilities.SetCapability("testdroid_testrun", "Android Run 1");
// See available devices at: https://cloud.testdroid.com/#public/devices
capabilities.SetCapability("testdroid_device", "Dell Venue 7 3730"); // Freemium device
capabilities.SetCapability("testdroid_app", "sample/BitbarSampleApp.apk"); //to use existing app using "latest" as fileUUID
Console.WriteLine ("WebDriver request initiated. Waiting for response, this typically takes 2-3 mins");
driver = new AndroidDriver<AndroidElement>(new Uri("http://appium.testdroid.com/wd/hub"), capabilities, TimeSpan.FromSeconds(180));
Console.WriteLine ("WebDriver response received.");
}
示例2: getIos82Caps
public static DesiredCapabilities getIos82Caps (string app) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "8.2");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone Simulator");
capabilities.SetCapability(MobileCapabilityType.App, app);
return capabilities;
}
示例3: BeforeScenario
public void BeforeScenario()
{
if (string.IsNullOrEmpty(_settings.Browser))
{
driver = new OpenQA.Selenium.PhantomJS.PhantomJSDriver();
}
else
{
//driver = new OpenQA.Selenium.PhantomJS.PhantomJSDriver();
var capabilities = new DesiredCapabilities();
// construct the url to sauce labs
Uri commandExecutorUri = new Uri("http://ondemand.saucelabs.com/wd/hub");
capabilities.SetCapability("username", _settings.Username); // supply sauce labs username
capabilities.SetCapability("accessKey", _settings.ApiKey);
// supply sauce labs account key
capabilities.SetCapability("name", TestContext.CurrentContext.Test.Name); // give the test a name
capabilities.SetCapability("timeZone", "Queensland");
capabilities.SetCapability("browserName", _settings.Browser); // "Chrome");
capabilities.SetCapability("platform", _settings.Platform); // "Windows 10");
capabilities.SetCapability("version", _settings.Version);
capabilities.SetCapability("build",
GetType().Assembly.GetName().Name + "_" +
Environment.GetEnvironmentVariable("SAUCELABS_BUILD_NUMBER"));
capabilities.SetCapability("name", ScenarioContext.Current.ScenarioInfo.Title);
// start a new remote web driver session on sauce labs
driver = new SessionAwareRemoteDriver(commandExecutorUri, capabilities);
}
// driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
ScenarioContext.Current["driver"] = driver;
}
示例4: BeforeScenario
public void BeforeScenario()
{
if (Process.GetProcessesByName("BrowserStackLocal").Length == 0)
new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "BrowserStackLocal.exe",
Arguments = ConfigurationManager.AppSettings["browserstack.key"] + " -forcelocal"
}
}.Start();
var capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.Version, ConfigurationManager.AppSettings["version"]);
capabilities.SetCapability("os", ConfigurationManager.AppSettings["os"]);
capabilities.SetCapability("os_version", ConfigurationManager.AppSettings["os_version"]);
capabilities.SetCapability("browserName", ConfigurationManager.AppSettings["browser"]);
capabilities.SetCapability("browserstack.user", ConfigurationManager.AppSettings["browserstack.user"]);
capabilities.SetCapability("browserstack.key", ConfigurationManager.AppSettings["browserstack.key"]);
capabilities.SetCapability("browserstack.local", true);
capabilities.SetCapability("project", "BrowserStack Demo");
capabilities.SetCapability("name", ScenarioContext.Current.ScenarioInfo.Title);
driver = new RemoteWebDriver(new Uri(ConfigurationManager.AppSettings["browserstack.hub"]), capabilities);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
ScenarioContext.Current["driver"] = driver;
}
示例5: SetUp
public void SetUp()
{
DesiredCapabilities Capabilities = new DesiredCapabilities();
Capabilities.SetCapability(CapabilityType.BrowserName, "firefox");
string GridURL = "http://localhost:4444/wd/hub";
Driver = new RemoteWebDriver(new Uri(GridURL), Capabilities);
}
示例6: StartingAndroidAppWithCapabilitiesAndServiceTest
public void StartingAndroidAppWithCapabilitiesAndServiceTest()
{
string app = Apps.get("androidApiDemos");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(MobileCapabilityType.DeviceName, "Android Emulator");
OptionCollector argCollector = new OptionCollector().AddArguments(GeneralOptionList.App(app))
.AddArguments(GeneralOptionList.AutomationName(AutomationName.Appium));
AppiumServiceBuilder builder = new AppiumServiceBuilder().WithArguments(argCollector);
AndroidDriver<AppiumWebElement> driver = null;
try
{
driver = new AndroidDriver<AppiumWebElement>(builder, capabilities);
driver.CloseApp();
}
finally
{
if (driver != null)
{
driver.Quit();
}
}
}
示例7: TestChromeBrowser
public void TestChromeBrowser()
{
//string appPath = @"D:\git-zjs\Appium-Test-ios-android\AppiumDriverDemo\Apps\UCBrowser_V9.8.0.435_Android_pf145_(Build14052717).apk";
string appPath = @"D:\git-zjs\Appium-Test-ios-android\AppiumDriverDemo\Apps\chrome.apk";
DesiredCapabilities cap = new DesiredCapabilities();
//cap.SetCapability("appium-version", "1.0");
cap.SetCapability(CapabilityType.BrowserName, "");
cap.SetCapability("platformName", "Android");
cap.SetCapability("browserName", "chrome");
cap.SetCapability("udid", "EAZSRK6HIJHEAYSK"); //三星手机 //4d00627749d2a037 红米手机 //EAZSRK6HIJHEAYSK 小米3 //bba1bd7
cap.SetCapability("app", appPath);
//UC Browser设置
//cap.SetCapability("app-package", "com.UCMobile");
//cap.SetCapability("app-activity", "com.uc.browser.InnerUCMobile");
//Chrome设置
//cap.SetCapability("app-package", "com.android.chrome");
//cap.SetCapability("app-activity", "com.google.android.apps.chrome.Main");
driver = new AppiumDriver(new Uri("http://localhost:4723/wd/hub"), cap);
Thread.Sleep(3000);
driver.Navigate().GoToUrl("http://m.ctrip.com");
Thread.Sleep(3000);
driver.FindElement(By.XPath("//li[@class=\"f\"]")).Click();
Thread.Sleep(3000);
driver.FindElement(By.XPath("//button[@id=\"searchlistsubmit88888888\"]")).Click();
Thread.Sleep(3000);
//driver.Quit();
}
示例8: getAndroid19Caps
public static DesiredCapabilities getAndroid19Caps (string app) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "");
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "4.4.2");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "Android Emulator");
capabilities.SetCapability(MobileCapabilityType.App, app);
return capabilities;
}
示例9: CommonBrowserStackBrowserFactory
/// <summary>
/// Configure mobile device browser
/// </summary>
public CommonBrowserStackBrowserFactory(string browserName, string platform, string device)
{
var caps = new DesiredCapabilities();
caps.SetCapability(DesiredCapsBrowserKey, browserName);
caps.SetCapability(DesiredCapsMobilePlatformKey, platform);
caps.SetCapability(DesiredCapsMobileDeviceKey, device);
commonCaps = caps;
}
示例10: beforeAll
public void beforeAll()
{
string appPath = @"D:\git-zjs\Appium-Test-ios-android\AppiumDriverDemo\Apps\ctrip_9013.apk";
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("udid", "EAZSRK6HIJHEAYSK"); // 真机
cap.SetCapability("app", appPath);
driver = new AppiumDriver(new Uri("http://localhost:4728/wd/hub"), cap);
Thread.Sleep(35000);
}
示例11: getIos71Caps
public static DesiredCapabilities getIos71Caps (string app) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "");
capabilities.SetCapability(MobileCapabilityType.AppiumVersion, "1.0");
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "7.1");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone Simulator");
capabilities.SetCapability(MobileCapabilityType.App, app);
return capabilities;
}
示例12: TestSetUp
public void TestSetUp()
{
//driver = new FirefoxDriver();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = DesiredCapabilities.Firefox();
capabilities.SetCapability(CapabilityType.BrowserName, "firefox");
capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);
}
示例13: Session
public Session(string testName, bool runAgainstLocalServer = false)
{
try {
RunningAgainstLocalServer = runAgainstLocalServer;
TempPath = Path.GetTempPath();
LogPath = Path.Combine(TempPath, "sauce_connect.log");
DriverCapabilities = DesiredCapabilities.Chrome();
DriverCapabilities.SetCapability(
CapabilityType.Platform, new Platform(PlatformType.Vista)
);
DriverCapabilities.SetCapability(
"name", testName
);
DriverCapabilities.SetCapability(
"username", SauceLabs.Credentials.username
);
DriverCapabilities.SetCapability(
"accessKey", SauceLabs.Credentials.accessKey
);
if (runAgainstLocalServer)
Proxy = StartProxy();
else
Proxy = null;
Console.Write("Starting browser... ");
try {
WebDriver = new RemoteWebDriver(
new Uri("http://ondemand.saucelabs.com:80/wd/hub"),
DriverCapabilities
);
Console.WriteLine("started.");
} catch (Exception exc) {
Console.WriteLine("failed.");
throw;
}
// Sauce doesn't support this :|
/*
WebDriver.Manage().Timeouts().SetPageLoadTimeout(
TimeSpan.FromSeconds(5)
);
WebDriver.Manage().Timeouts().SetScriptTimeout(
TimeSpan.FromSeconds(1)
);
*/
} catch (Exception exc2) {
Dispose();
throw;
}
}
示例14: InitBrowser
public void InitBrowser()
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("deviceName", "AF2");
capabilities.SetCapability("app", "D:/BYTA/Framework/BYTA_AF_Framework_Task5/MobileTests/com.basecamp.bc3.apk");
capabilities.SetCapability("appPackage", "com.basecamp.bc3");
capabilities.SetCapability("appWaitActivity", "com.basecamp.bc3.activities.AuthChooserActivity");
capabilities.SetCapability("unicodeKeyboard", true);
driver = new AndroidDriver<IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
}
示例15: TestClass
public TestClass()
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("appium-version", "1.0");
capabilities.SetCapability("platformName", "iOS");
capabilities.SetCapability("platformVersion", "7.1");
capabilities.SetCapability("deviceName", "iPhone Simulator");
capabilities.SetCapability("app", "/Users/i51375/Code/xactimate.ios/Xactimate.iOS/bin/Debug/XactimateiOS.app");
driver = new AppiumDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
}