当前位置: 首页>>代码示例>>C#>>正文


C# Remote.DesiredCapabilities类代码示例

本文整理汇总了C#中OpenQA.Selenium.Remote.DesiredCapabilities的典型用法代码示例。如果您正苦于以下问题:C# DesiredCapabilities类的具体用法?C# DesiredCapabilities怎么用?C# DesiredCapabilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DesiredCapabilities类属于OpenQA.Selenium.Remote命名空间,在下文中一共展示了DesiredCapabilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Environment

 internal Environment()
 {
     string browserVersion = Configuration.BrowserVersion;
     string platform = Configuration.Platform;
     _capability = new DesiredCapabilities(_browserName, browserVersion, new Platform(NormalizePlatformName(platform)));
     Logger.Log("[browser: " + _browserName + "; version: " + browserVersion + "; platform: " + platform + "; isUsingGrid: " + _isUsingGrid + "]", LogType.Delimiter);
 }
开发者ID:sadeghsm,项目名称:ChronoZoom,代码行数:7,代码来源:Environment.cs

示例2: 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);
 }
开发者ID:GruLab,项目名称:elemental-selenium-tips,代码行数:7,代码来源:Grid.cs

示例3: 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.");


		}
开发者ID:mneiferbag,项目名称:testdroid-samples,代码行数:29,代码来源:Tests.cs

示例4: LaunchBrowser

        /// <summary>
        /// Launches the Selenium WebDriver driven browser specified in the Environments.cs file
        /// </summary>
        public IWebDriver LaunchBrowser(IWebDriver driver)
        {
            switch(this.environment.browser)
            {
                case "*firefox":
                    _ffp = new FirefoxProfile();
                    _ffp.AcceptUntrustedCertificates = true;
                    driver = new FirefoxDriver(_ffp);
                    break;
                case "*iexplore":
                    driver = new InternetExplorerDriver();
                    break;
                case "*googlechrome":
                    driver = new ChromeDriver();
                    break;
                case "Android":
                    capabilities = new DesiredCapabilities("android", "", null);
                    capabilities.IsJavaScriptEnabled = true;
                    driver = new RemoteWebDriver(new Uri(string.Format("http://{0}:{1}/hub", environment.host, environment.port)), capabilities);
                    break;
                case "RemoteWebDriver":
                    capabilities = DesiredCapabilities.Firefox();
                    var remoteAddress = new Uri(string.Format("http://{0}:{1}/wd/hub", environment.host, environment.port));
                    driver = new RemoteWebDriver(remoteAddress, capabilities);
                    break;
            }

            return driver;
        }
开发者ID:tmacblane,项目名称:TestManager,代码行数:32,代码来源:WebBrowser.cs

示例5: 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;
		}
开发者ID:AndreaChG,项目名称:SpecFlow.BrowserStack,代码行数:31,代码来源:Setup.cs

示例6: RunBeforeEach

		public void RunBeforeEach()
		{
			server.respondToInit ();
			DesiredCapabilities capabilities = new DesiredCapabilities();
            AndroidDriver driver = new AndroidDriver(defaultUri, capabilities);
			server.clear ();
		}
开发者ID:andreypetukhov,项目名称:AppiumGigya,代码行数:7,代码来源:SessionTest.cs

示例7: GetCapabilities

//        public CapabilitiesFactory()
//        {
//        }
        
        public static ICapabilities GetCapabilities()
        {
            ICapabilities cap = new DesiredCapabilities();
            
            
            return cap;
        }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:11,代码来源:CapabilitiesFactory.cs

示例8: 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;
        }
开发者ID:FlawlessFalcon,项目名称:sample-code,代码行数:7,代码来源:Caps.cs

示例9: 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();
                }
            }
        }
开发者ID:FlawlessFalcon,项目名称:sample-code,代码行数:25,代码来源:StartingAppLocallyTest.cs

示例10: 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;
        }
开发者ID:rovens,项目名称:specflowdemo,代码行数:34,代码来源:Setup.cs

示例11: when_logging_in_with_an_invalid_username_and_password

        public void when_logging_in_with_an_invalid_username_and_password()
        {
            var capabilities = new DesiredCapabilities();
            capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);

            var driver = new InternetExplorerDriver(capabilities);

            try
            {
                driver.Navigate().GoToUrl("http://localhost:52125/Account/LogOn");

                driver.FindElement(By.Name("UserName")).SendKeys("[email protected]");
                driver.FindElement(By.Name("Password")).SendKeys("BadPass");
                driver.FindElement(By.TagName("form")).Submit();

                driver.Url.ShouldEqual("http://localhost:52125/Account/LogOn");

                driver.FindElement(By.ClassName("validation-summary-errors")).Text.ShouldContain(
                    "The user name or password provided is incorrect.");
            }
            finally
            {
                driver.Close();
            }
        }
开发者ID:rajeshpillai,项目名称:SpecsFor,代码行数:25,代码来源:LoginSpecsWithoutSpecsForMvc.cs

示例12: Main

 static void Main(string[] args)
 {
     try
     {
         var stopWatch = Stopwatch.StartNew();
         DesiredCapabilities capabilities = new DesiredCapabilities();
         var driverService = ChromeDriverService.CreateDefaultService(@"E:\");
         driverService.HideCommandPromptWindow = true;
         var webDriver = new InternetExplorerDriver();
         webDriver.Navigate().GoToUrl("http://www.udebug.com/UVa/10812");
         IWebElement inputBox = webDriver.FindElement(By.Id("edit-input-data"));
         inputBox.SendKeys("3\n2035415231 1462621774\n1545574401 1640829072\n2057229440 1467906174");
         IWebElement submitButton = webDriver.FindElement(By.Id("edit-output"));
         submitButton.SendKeys("\n");
         submitButton.Click();
         string answer = webDriver.PageSource;
         int begin = answer.IndexOf("<pre>") + 5;
         answer = answer.Substring(begin, answer.IndexOf("</pre>") - begin);
         Console.WriteLine(answer);
         webDriver.Close();
         Console.WriteLine(stopWatch.ElapsedMilliseconds);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.Message);
     }
 }
开发者ID:HuyTranQ,项目名称:UvaLocalJudge,代码行数:27,代码来源:Program.cs

示例13: logging_in_with_invalid_credentials

        public void logging_in_with_invalid_credentials()
        {
            var capabilities = new DesiredCapabilities();
            capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);

            var driver = new InternetExplorerDriver(capabilities);
            driver.Navigate().GoToUrl(TargetAppUrl + "/Authentication/LogOff");

            try
            {
                driver.Navigate().GoToUrl(TargetAppUrl + "/LogOn");

                driver.FindElement(By.Name("EmailAddress")).SendKeys("[email protected]");
                driver.FindElement(By.Name("Password")).SendKeys("BadPass");
                driver.FindElement(By.TagName("form")).Submit();

                driver.Url.ShouldEqual(TargetAppUrl + "/LogOn");

                driver.FindElement(By.ClassName("validation-summary-errors")).Text.ShouldContain(
                    "The user name or password provided is incorrect.");
            }
            finally
            {
                driver.Close();
            }
        }
开发者ID:williamflock,项目名称:Fail-Tracker,代码行数:26,代码来源:AuthenticationSpecs.cs

示例14: InitializeDriver

        public virtual void InitializeDriver()
        {
            InitializeSettings();

            switch (BrowserType)
            {
                case BrowserType.Chrome:
                    var chromeOptions = new ChromeOptions();
                    chromeOptions.AddArguments(new string[] { "--no-sandbox", "test-type", "--start-maximized" });
                    var chromeDriverService = ChromeDriverService.CreateDefaultService();
                    chromeDriverService.HideCommandPromptWindow = false;
                    Context.Driver = new ChromeDriver(chromeDriverService, chromeOptions, TimeSpan.FromSeconds(300.0));
                break;
                case BrowserType.Firefox:
                    var capabilities = new DesiredCapabilities();
                    capabilities.SetCapability(CapabilityType.UnexpectedAlertBehavior, "dismiss");
                    Context.Driver = new FirefoxDriver(capabilities);
                break;

            }

            Context.Browser = new Browser();
            Context.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Context.Settings.WaitTimeout));
            Context.Driver.Navigate().GoToUrl("about:blank");
            Context.Driver.SwitchTo().Window(Context.Driver.WindowHandles.First());
        }
开发者ID:alexx-ivanoff,项目名称:StreamTVautomation,代码行数:26,代码来源:TestFixtureBase.cs

示例15: Init

        public void Init()
        {
            testParams = PNUnitServices.Get().GetTestParams();
            String params1 = String.Join(",", testParams);
            Console.WriteLine(params1);
            String browser = testParams[0];
            String version = testParams[1];
            String os = testParams[2];
            String os_version = testParams[3];
            String platform = testParams[4];
            String device = testParams[5];
            DesiredCapabilities capability = new DesiredCapabilities();
            capability.SetCapability("browserName", browser);
            capability.SetCapability(CapabilityType.Version, version);
            capability.SetCapability("os", os);
            capability.SetCapability("os_version", os_version);
            capability.SetCapability("platform", platform);
            capability.SetCapability("device", device);
            capability.SetCapability("browserstack.user", "<USERNAME>");
            capability.SetCapability("browserstack.key", "<ACCESS_KEY>");

            Console.WriteLine("Capabilities" + capability.ToString());

            driver = new RemoteWebDriver(new Uri("http://hub.browserstack.com:80/wd/hub/"), capability);
        }
开发者ID:NishantPanchal92,项目名称:BrowserStack-PNUnit,代码行数:25,代码来源:Class1.cs


注:本文中的OpenQA.Selenium.Remote.DesiredCapabilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。