Exemple #1
0
 private static ICapabilities ConvertOptionsToCapabilities(FirefoxOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException("options", "options must not be null");
     }
     return(options.ToCapabilities());
 }
Exemple #2
0
        private static ICapabilities ConvertOptionsToCapabilities(FirefoxOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options", "options must not be null");
            }

            ICapabilities capabilities = options.ToCapabilities();

            if (options.UseLegacyImplementation)
            {
                capabilities = RemoveUnneededCapabilities(capabilities);
            }

            return(capabilities);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            FirefoxOptions option = new FirefoxOptions();
            ICapabilities cap = option.ToCapabilities();

            FirefoxProfileManager mangage = new FirefoxProfileManager();
            FirefoxProfile profile = mangage.GetProfile(mangage.ExistingProfiles[0]);

            IWebDriver driver = new FirefoxDriver(profile);

            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60));
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("https://www.baidu.com/");
            IWebElement input = driver.FindElement(By.Id("kw"));
            input.SendKeys("shinetech");
            IWebElement search = driver.FindElement(By.Id("su"));
            search.Click();
            IWebElement shinetech = driver.FindElement(By.XPath("//div[@id='1']/h3/a"));
            if(shinetech!=null)
            {
                if(shinetech.Text.Contains("盛安德"))
                {
                    Console.WriteLine("Find shinetech, test passed");
                }
                else
                {
                    Console.WriteLine("Cannot find Shinetech, test case failed");
                }
            }
            else
            {
                Console.WriteLine("Cannot find Shinetech, test case failed");
            }
            shinetech.Click();
            driver.Dispose();
        }
Exemple #4
0
        private static ICapabilities ConvertOptionsToCapabilities(FirefoxOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options", "options must not be null");
            }

            return options.ToCapabilities();
        }
Exemple #5
0
        private static ICapabilities ConvertOptionsToCapabilities(FirefoxOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options", "options must not be null");
            }

            ICapabilities capabilities = options.ToCapabilities();
            if (options.UseLegacyImplementation)
            {
                capabilities = RemoveUnneededCapabilities(capabilities);
            }

            return capabilities;
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FirefoxDriver"/> class using the specified options, driver service, and timeout. Uses the Mozilla-provided Marionette driver implementation.
 /// </summary>
 /// <param name="service">The <see cref="FirefoxDriverService"/> to use.</param>
 /// <param name="options">The <see cref="FirefoxOptions"/> to be used with the Firefox driver.</param>
 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
 public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)
     : base(new DriverServiceCommandExecutor(service, commandTimeout), options.ToCapabilities())
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FirefoxDriver"/> class using the specified options, driver service, and timeout. Uses the Mozilla-provided Marionette driver implementation.
 /// </summary>
 /// <param name="service">The <see cref="FirefoxDriverService"/> to use.</param>
 /// <param name="options">The <see cref="FirefoxOptions"/> to be used with the Firefox driver.</param>
 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
 public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)
     : base(new DriverServiceCommandExecutor(service, commandTimeout), options.ToCapabilities())
 {
 }