Manage() public method

Method For getting an object to set the Speen
public Manage ( ) : IOptions
return IOptions
コード例 #1
1
ファイル: WebDriver.cs プロジェクト: chriscore/SpecDriver
        public static IWebDriver CreateChromeGridDriver(string profileName, string hubAddress)
        {
            if (hubAddress == null)
            {
                throw new ArgumentException("remoteAddress");
            }

            var chromeOptions = new ChromeOptions();
            if (!string.IsNullOrWhiteSpace(profileName))
            {
                var fileChars = Path.GetInvalidFileNameChars();
                var pathChars = Path.GetInvalidFileNameChars();
                var invalidChars = fileChars.Union(pathChars);

                profileName = String.Join("", profileName.Where(c => !invalidChars.Contains(c)));

                chromeOptions.AddArguments(String.Format("user-data-dir=c:\\ChromeProfiles\\{0}", profileName));
            }

            RemoteWebDriver Driver = new RemoteWebDriver(new Uri(hubAddress), chromeOptions.ToCapabilities());

            Driver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(0, 1, 0));
            Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 1));
            Driver.Manage().Window.Maximize();
            return Driver;
        }
コード例 #2
0
ファイル: Test.cs プロジェクト: sergueik/selenium_java
 public void MyTestInitialize()
 {
     verificationErrors = new StringBuilder();
     DesiredCapabilities capability = DesiredCapabilities.Firefox();
     driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);
     driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
     driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(50));
     driver.Manage().Window.Maximize();
     driver.Navigate();
 }
コード例 #3
0
ファイル: ChromeTests.cs プロジェクト: gidavies/SimpleDemoApp
        public static void ClassInit(TestContext context)
        {
            // Chrome specifics
            _webDriver = new ChromeDriver(@"C:\Tools");

            //Set page load timeout to 20 seconds (occasionally 5 secs is too tight after a deployment)
            _webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(20));

            try
            {
                // Get the URL for the current environment (e.g. Dev, QA, Prod) as set in the release environment
                string releaseEnvironmentAppBaseURL = Environment.GetEnvironmentVariable("WebAppName");
                if (releaseEnvironmentAppBaseURL != null)
                {
                    _webAppBaseURL = "http://" + releaseEnvironmentAppBaseURL + ".azurewebsites.net";
                    Console.WriteLine("WebApp Base URL found: " + _webAppBaseURL);
                }
                else
                {
                    // The environment variable exists but has no value, so use a default
                    _webAppBaseURL = _defaultWebAppBaseURL;
                    Console.WriteLine("WebApp Base URL not set, using default: " + _defaultWebAppBaseURL);
                }
            }
            catch (Exception Ex)
            {
                // The environment variable probably doesn't exist (might be called from within VS)
                Console.WriteLine("Exception thrown accessing environment variable: " + Ex.Message);
                Console.WriteLine("Using default: " + _defaultWebAppBaseURL);
                _webAppBaseURL = _defaultWebAppBaseURL;
            }
        }
コード例 #4
0
ファイル: WebDriverSetup.cs プロジェクト: VNikita/Test_auto
        public static RemoteWebDriver getWebDriver(string DriverName = "")
        {
            if (WebDriver == null)
            {
                switch (DriverName)
                {
                    case "IE":
                        var options = new InternetExplorerOptions();
                        options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                        WebDriver = new InternetExplorerDriver(/*Settings.CurrentSettings.BrowserPath,*/ options);

                        //IeCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
                //WebDriver = new InternetExplorerDriver(ieCapabilities);
                        break;
                    case "CHROME":
                    default:
                        WebDriver = new ChromeDriver();
                        break;
                }
                /*System.setProperty("webdriver.ie.driver", "src\\test\\resources\\drivers\\IEDriverServer.exe");
                DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
                ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
                webDriver = new InternetExplorerDriver(ieCapabilities);
                webDriver.manage().timeouts()
                        .implicitlyWait(WAIT_TIMEOUT, TimeUnit.MILLISECONDS);
                maximizeBrowser();*/
                WebDriver.Manage().Timeouts()
                        .ImplicitlyWait(TimeSpan.FromSeconds(WAIT_TIMEOUT));
                MaximizeBrowser();
            }

            return WebDriver;
        }
コード例 #5
0
        public static void MyTestInitialize(TestContext testContext)
        {
            verificationErrors = new StringBuilder();
            try
            {
                // driver = new InternetExplorerDriver(IE_DRIVER_PATH);

                DesiredCapabilities capability = DesiredCapabilities.Firefox();
                driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);

                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
                driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(50));

            }
            catch (Exception ex) { }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: Qianfinland/Net
        public void Selenium_Server_Test()
        {
            IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.Firefox());
            driver.Url = "http://www.google.com";
            var searchBox = driver.FindElement(By.Id("lst-ib"));
            searchBox.SendKeys("Lotus flower");
            searchBox.SendKeys(Keys.Enter);

            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            var imagetext = driver.FindElement(By.LinkText("Kuvahaku"));
            Assert.That(imagetext.Text, Is.EqualTo("Kuvahaku"));
            imagetext.Click();

            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); //avoid error on no such element
            var imagelistId = driver.FindElement(By.Id("rg_s"));
            var fouthdivclass = imagelistId.FindElements(By.CssSelector("[class='rg_di rg_el ivg-i']"))[1].FindElement(By.TagName("a"));
            fouthdivclass.Click();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            var ImageLink = driver.FindElement(By.LinkText("Näytä kuva"));
            ImageLink.Click();
        }
コード例 #7
0
        public void BeforeScenario()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.SetCapability(CapabilityType.BrowserName, Environment.GetEnvironmentVariable("browserName"));
            capabilities.SetCapability(CapabilityType.Version, Environment.GetEnvironmentVariable("version"));
            capabilities.SetCapability(CapabilityType.Platform, Environment.GetEnvironmentVariable("platformOs"));
            capabilities.SetCapability("username", Environment.GetEnvironmentVariable("SAUCE_USERNAME"));
            capabilities.SetCapability("accessKey", Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY"));
            capabilities.SetCapability("name", ScenarioContext.Current.ScenarioInfo.Title);

            RemoteWebDriver webDriver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), capabilities, TimeSpan.FromSeconds(600));
            webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
            ScenarioContext.Current["driver"] = webDriver;
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: TylerTan/SeleniumGridDemo
        static void Main(string[] args)
        {
            DesiredCapabilities capability = null;
            IWebDriver driver = null;
            for (int i = 1; i < 4; i++)
            {
                switch (i)
                {
                    case 1:
                        capability = DesiredCapabilities.Firefox();
                        capability.SetCapability("BrowserName", "firefox");
                        break;
                    case 2:
                        capability = DesiredCapabilities.Chrome();
                        capability.SetCapability("BrowserName", "chrome");
                        break;
                    case 3:
                        capability = DesiredCapabilities.InternetExplorer();
                        capability.SetCapability("BrowserName", "internet explorer");
                        break;
                    default:
                        return;
                }

                driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);
                driver.Manage().Window.Maximize();
                driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(10));
                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
                driver.Navigate().GoToUrl("http://www.baidu.com");
                IWebElement searchBox = driver.FindElement(By.Id("kw"));
                IWebElement searchButton = driver.FindElement(By.Id("su"));
                searchBox.SendKeys("Shinetech");
                searchButton.Click();
                driver.Dispose();
            }
        }
コード例 #9
0
        public void TitleIsCorrect()
        {
            for (int i = 0; i < 30; i++)
            {
                //IWebDriver webDriver = new ChromeDriver();
                //IWebDriver webDriver = new PhantomJSDriver();
                // TODO ^^ So instead of this we do this:
                IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:4444"), new DesiredCapabilities());
                // ^^ this is how you'd call a Selenium Grid server, the desired capability is used to ask for a particular browser (or set of configuration)
                // you will need to first run phantomjs.exe --webdriver=4444
                // you might run a local instance simply by calling java -jar selenium-grid.jar or something, then register browsers with it
                // you could also call source labs, browserstack or whatever

                // When using ChromeDriver you could try reuisng a webdriver session,
                // but then you could get failing tests interfering with other tests, you can do some work to mitigation this and use things like cookejars to isolate tests
                // but with PhantomJS giving you a new session each time, you don't have to worry about it.

                // we had it so that failures would output a screenshot (that would get attached to the test result), this is available through the webdriver api and is support by PhantomJS
                // we also had the webdriver switchable by config, so that we could quickly switch to a full browser to troubleshoot bugs

                webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));


                webDriver.Navigate().GoToUrl("http://localhost:3988/");
                var header = webDriver.FindElement(By.CssSelector("div.jumbotron > h1"));
                header.Text.ShouldBe("ASP.NET");
            }

            //var liCount = _webDriver.FindElement(By.Id("test-content")).FindElements(By.TagName("li")).Count;

            //liCount.ShouldBe(3);

            // This sort of fiddly stuff, i.e. elements with timeouts, domReady etc... are not as bad as I remember.
            // because FindElements will wait using the _webdriver implicit wait settings (set when we construct the WebDriver object)
            // but what if there was already an <li> in the list, it fails! what if the dom exists, but then we replace it with ajax

            // thats when you might do something explicit like this:

            //var fiveSecondWait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(5));
            //fiveSecondWait.Until(wd =>
            //{
            //    // do some checks
            //    return true;
            //});

            // We used to queue some javascript so that we know that all synchrounous task had been parse and completed by the browser and we were ready to rock
        }
コード例 #10
0
        /// <summary>starts a sauce labs sessions</summary>
        /// <param name="browser">name of the browser to request</param>
        /// <param name="version">version of the browser to request</param>
        /// <param name="platform">operating system to request</param>
        private IWebDriver _Setup(string browser, string version, string platform)
        {
            // construct the url to sauce labs
            Uri commandExecutorUri = new Uri("<http://ondemand.saucelabs.com/wd/hub>");
            // set up the desired capabilities
            DesiredCapabilities desiredCapabilites = new DesiredCapabilities(browser, version, Platform.CurrentPlatform); // set the desired browser
            desiredCapabilites.SetCapability("platform", platform); // operating system to use
            desiredCapabilites.SetCapability("username", Constants.SAUCE_LABS_ACCOUNT_NAME); // supply sauce labs username
            desiredCapabilites.SetCapability("accessKey", Constants.SAUCE_LABS_ACCOUNT_KEY);  // supply sauce labs account key
            desiredCapabilites.SetCapability("name", TestContext.CurrentContext.Test.Name); // give the test a name

            // start a new remote web driver session on sauce labs
            var _Driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilites);
            _Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));

            // navigate to the page under test
            _Driver.Navigate().GoToUrl("<https://saucelabs.com/test/guinea-pig>");

            return _Driver;
        }
コード例 #11
0
ファイル: TestManager.cs プロジェクト: ngocluu263/WebAuto
        public CommandExecutionResult Execute(UITestSuite[] testSuites, WebAutoConfiguration configuration)
        {
            if (!Directory.Exists(configuration.ResultsFolder))
                Directory.CreateDirectory(configuration.ResultsFolder);

            CommandExecutionResult result = new CommandExecutionResult { CommandResult = CommandResult.Success, Message = string.Empty };
            Assembly assembly = Assembly.LoadFrom("WebAuto.Commands.dll");

            var uiMap = Repository.GetUIMap(configuration.UIMapFile);
            foreach (var testSuite in testSuites)
            {
                Console.WriteLine(testSuite.Name);
                foreach (var testcase in testSuite)
                {
                    Console.WriteLine(string.Format(" {0}", testcase.Value.GroupName));
                    var dataBucket = Repository.GetData(Path.Combine(configuration.DataDirectory, testcase.Value.GroupName + configuration.FileExtension));

                    IWebDriver driver = null;
                    switch (configuration.Browser)
                    {
                        case "firefox":
                            driver = new FirefoxDriver();
                            break;
                        case "chrome":
                            driver = new ChromeDriver();
                            break;
                        case "ie":
                            driver = new InternetExplorerDriver();
                            break;
                        case "htmlunit":
                            driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript());
                            break;
                        default:
                            driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnit());
                            break;
                    }
                    driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 20));
                    new Utility().ResizeTest(driver);

                    var usedData = new Dictionary<string, int>();
                    foreach (var sequence in testcase.Value.CommandGroups.Sequences)
                    {
                        var commandContainer = new UICommandContainer();
                        commandContainer.Name = sequence.Value.Name;

                        Console.WriteLine(string.Format("  {0}", sequence.Value.Name));

                        if (!usedData.ContainsKey(sequence.Value.Name))
                        {
                            usedData.Add(sequence.Value.Name, 1);
                        }
                        else
                        {
                            usedData[sequence.Value.Name]++;
                        }

                        var dataName = usedData[sequence.Value.Name] > 1
                                       	? string.Format("{0}({1})", sequence.Value.Name.ToLower(), usedData[sequence.Value.Name])
                                       	: sequence.Value.Name.ToLower();

                        // check if sequence uses a list table
                        if (dataBucket.DataTables.ContainsKey(dataName))
                        {
                            var table = dataBucket.DataTables[dataName];
                            foreach (var dataValue in table)
                            {
                                foreach (var command in sequence.Value.Commands)
                                {
                                    var c = new UICommand()
                                    {
                                        CommandName = command.CommandName,
                                        Description = command.Description ?? string.Empty,
                                        Target = command.Target ?? string.Empty,
                                        Value = command.Value ?? string.Empty
                                    };
                                    var cmd = PrepareCommand(c, dataValue, uiMap);
                                    Console.WriteLine(string.Format("   {0} {1} {2}",
                                        cmd.CommandName,
                                        cmd.Target,
                                        cmd.Value));

                                    string className = "WebAuto.Commands." + Utility.UppercaseFirst(cmd.CommandName) + "Command";
                                    Type t = assembly.GetType(className);
                                    var cmd2 = (WebAuto.Interfaces.Command)Activator.CreateInstance(t);
                                    cmd2.CommandName = cmd.CommandName;
                                    cmd2.Description = cmd.Description;
                                    cmd2.Target = cmd.Target;
                                    cmd2.Value = cmd.Value;

                                    ((ICommand) cmd2).Execute(driver);
                                }
                            }
                        }
                        else
                        {
                            foreach (var command in sequence.Value.Commands)
                            {
                                var c = new UICommand()
                                {
                                    CommandName = command.CommandName,
                                    Description = command.Description ?? string.Empty,
                                    Target = command.Target ?? string.Empty,
                                    Value = command.Value ?? string.Empty
                                };
                                var cmd = PrepareCommand(command, dataBucket.DataValues[dataName], uiMap);
                                Console.WriteLine(string.Format("   {0} {1} {2}",
                                        cmd.CommandName,
                                        cmd.Target,
                                        cmd.Value));

                                string className = "WebAuto.Commands." + Utility.UppercaseFirst(cmd.CommandName) + "Command";
                                Type t = assembly.GetType(className);
                                var cmd2 = (WebAuto.Interfaces.Command)Activator.CreateInstance(t);
                                cmd2.CommandName = cmd.CommandName;
                                cmd2.Description = cmd.Description;
                                cmd2.Target = cmd.Target;
                                cmd2.Value = cmd.Value;

                                ((ICommand)cmd2).Execute(driver);
                            }
                        }
                    }
                    driver.Close();
                }
            }
            return result;
        }
コード例 #12
0
ファイル: DriverFactory.cs プロジェクト: dburriss/UiMatic
        private static IWebDriver SauceLabsDriverInstance(string platform, string browser, string version, string testName)
        {
            // construct the url to sauce labs
            Uri commandExecutorUri = new Uri(SauceLabsConstants.Url);

            // set up the desired capabilities
            DesiredCapabilities desiredCapabilites = new DesiredCapabilities(browser, version, Platform.CurrentPlatform); // set the desired browser
            desiredCapabilites.SetCapability("platform", platform); // operating system to use
            desiredCapabilites.SetCapability("username", SauceLabsConstants.AccountName); // supply sauce labs username
            desiredCapabilites.SetCapability("accessKey", SauceLabsConstants.AccountKey);  // supply sauce labs account key
            //desiredCapabilites.SetCapability("name", TestContext.CurrentContext.Test.Name); // give the test a name
            desiredCapabilites.SetCapability("name", testName);

            // start a new remote web driver session on sauce labs
            var driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilites);
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30));

            return driver;
        }
コード例 #13
0
 public void SetupTest()
 {
     _driver = new FirefoxDriver();
     _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
 }
コード例 #14
0
ファイル: UnitTest1.cs プロジェクト: rainymaple/WebTester
        private IWebDriver SetupSauceLabsDirver()
        {
            // construct the url to sauce labs
            var commandExecutorUri = new Uri("http://ondemand.saucelabs.com/wd/hub");

            // set up the desired capabilities
            var desiredCapabilites = new DesiredCapabilities(SaucelabsBrowser, SaucelabsBrowserVersion, Platform.CurrentPlatform);
            // set the desired browser
            desiredCapabilites.SetCapability("platform", SaucelabsPlatform); // operating system to use
            desiredCapabilites.SetCapability("username", Constants.SAUCE_LABS_ACCOUNT_NAME);
            // supply sauce labs username
            desiredCapabilites.SetCapability("accessKey", Constants.SAUCE_LABS_ACCOUNT_KEY);
            // supply sauce labs account key
            desiredCapabilites.SetCapability("name", "IMS DEMO test"); // give the test a name

            // start a new remote web driver session on sauce labs
            IWebDriver remoteDriver = new RemoteWebDriver(commandExecutorUri, desiredCapabilites);
            remoteDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
            remoteDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30));

            // navigate to the page under test
            //remoteDriver.Navigate().GoToUrl("https://saucelabs.com/test/guinea-pig");

            return remoteDriver;
        }
コード例 #15
0
ファイル: PageBase.cs プロジェクト: BO45/NzbDrone
 public PageBase(RemoteWebDriver driver)
 {
     _driver = driver;
     driver.Manage().Window.Maximize();
 }
コード例 #16
0
 public void GetDriver(string url)
 {
     Driver = new FirefoxDriver();
     Driver.Manage().Window.Maximize();
     NavigateTo(url);
 }
コード例 #17
0
        private static void ValidatePage(RemoteWebDriver _driver ,Uri currentUri ,Uri parentUri)
        {
            PageInfoToExcel pageInfo = new PageInfoToExcel();
            
            List<LogEntry> logEntry = _driver.Manage().Logs.GetLog(LogType.Browser).ToList();
            Boolean ValidateFailed = false;

            if (_driver.PageSource.Contains("Error 404") || _driver.PageSource.Contains("404") || _driver.PageSource.ToLower().Contains("not found"))
            {
                pageInfo.NotFound= " Page Not Found";
                ValidateFailed = true;
            }
            if (logEntry.Count > 0)
            {

                pageInfo.LogCount = logEntry.Count.ToString();
                pageInfo.Error += string.Join(" , ", logEntry.Where(log => !log.Message.Contains("$modal is now deprecated. Use $uibModal instead.")).Select(log => log.Message).ToList());
                ValidateFailed = true;
            }
            if (ValidateFailed)
            {
                pageInfo.SourceURL = parentUri != null ?parentUri.ToString(): "";
                pageNotFoundMapping.TryAdd(currentUri, pageInfo);
            }

        }
コード例 #18
0
		/// <summary>
		/// Opens a new browser window.
		/// </summary>
		public static void Open()
		{
			try
			{
				//Here we read the type of webdriver we want from the app settings, then create an instance of it
				_webDriver = (RemoteWebDriver)Activator.CreateInstance("WebDriver", Setup.Settings.Browser).Unwrap();				
			}
			catch (ArgumentNullException e1)
			{
				Console.WriteLine("Browser was not found. Check a browser has been chosen in the app.config file. " + e1.Message);
				throw;
			}
			catch (TargetInvocationException e2)
			{
				Console.WriteLine("Browser.Open() encountered an error. Check Driver location. " + e2.Message);
				throw;
			}
			catch (Exception e3)
			{
				Console.WriteLine("Browser.Open() encountered an error. " + e3.Message);
				throw;
			}

			_webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));

			MaximizeWindow();
		}
コード例 #19
0
ファイル: Factory.cs プロジェクト: buonan/SeleniumTests
        private static IWebDriver _CreateInstance(DesiredCapabilities caps, Drivers driver)
        {
            IWebDriver _webdriver = null;
            if (caps == null) {
                //
                // Loaded default caps for RemoteWebDriver from Selenium.Tests.dll.config in current Dll directory
                // See brian.ku about user/key
                //
                caps = new DesiredCapabilities();
                caps.SetCapability("browserstack.user", ConfigurationManager.AppSettings["browserstack.user"]);
                caps.SetCapability("browserstack.key", ConfigurationManager.AppSettings["browserstack.key"]);
                caps.SetCapability("browser", ConfigurationManager.AppSettings["browser"]);
                caps.SetCapability("browser_version", ConfigurationManager.AppSettings["browser_version"]);
                caps.SetCapability("os", ConfigurationManager.AppSettings["os"]);
                caps.SetCapability("os_version", ConfigurationManager.AppSettings["os_version"]);
                caps.SetCapability("resolution", ConfigurationManager.AppSettings["resolution"]);
                caps.SetCapability("browserstack.debug", ConfigurationManager.AppSettings["browserstack.debug"]);
                caps.SetCapability("browserstack.local", ConfigurationManager.AppSettings["browserstack.local"]);
            }
            switch (driver) {
            case Drivers.IEDriver:
                InternetExplorerDriverService ieService = InternetExplorerDriverService.CreateDefaultService();
                _webdriver = new InternetExplorerDriver(ieService, new InternetExplorerOptions(), TimeSpan.FromSeconds(3 * 60));
                break;
            case Drivers.ChromeDriver:
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.AddExcludedArgument("ignore-certifcate-errors");
                chromeOptions.AddArgument("test-type");
                _webdriver = new ChromeDriver(chromeOptions);
                _webdriver.Manage().Window.Maximize();
                break;
            case Drivers.FirefoxDriver:
                FirefoxProfile profile = new FirefoxProfile();
                _webdriver = new FirefoxDriver(profile);
                _webdriver.Manage().Window.Maximize();
                break;
            case Drivers.BrowserStack:
                caps.SetCapability("ensureCleanSession", true);
                _webdriver = new RemoteWebDriver(new Uri(ConfigurationManager.AppSettings["remotewebdriver_url"]), caps);
                //_webdriver.Manage().Window.Maximize();
                break;
            case Drivers.LocalStack:
                //
                // Start the local BrowserStack proxy for cloud browser access
                //
                bool bConnected = false;
                do {
                    //
                    // Reset the stdout capture
                    //
                    sbOutput = new StringBuilder();

                    //
                    // check if connection succeeeded
                    //
                    bConnected = LaunchBrowserStackLocalProcess();
                } while (!bConnected);

                _webdriver = new RemoteWebDriver(new Uri(ConfigurationManager.AppSettings["remotewebdriver_url"]), caps, TimeSpan.FromMinutes(5.0));
                break;
            }
            //
            // Set an implicit timeout for all FindElements
            //
            _webdriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Factory.DefaultTimeoutValue));

            return _webdriver;
        }
コード例 #20
0
        protected void TestHappyPath(RemoteWebDriver browser)
        {
            browser.Manage().Window.Size = new Size(450, 600);

            LaunchPageTest(browser, url);
            System.Threading.Thread.Sleep(_testStepInterval);

            //login/registration -----------------------------------------------
            LoginTest(browser, "test", "test", true);
            System.Threading.Thread.Sleep(_testStepInterval);

            TestRegistration(browser, "testUser", "testUser23", "*****@*****.**", true);
            System.Threading.Thread.Sleep(_testStepInterval);

            LoginTest(browser, "testUser", "testUser23", false);
            System.Threading.Thread.Sleep(_testStepInterval);

            LogOut(browser);
            System.Threading.Thread.Sleep(_testStepInterval);

            LoginTest(browser, "testUser", "testUser23", false);
            System.Threading.Thread.Sleep(_testStepInterval);

            //menu tests -------------------------------------------------------
            AddItem(browser, "Bucket item test 1", "Hot");
            System.Threading.Thread.Sleep(_testStepInterval);

            //edit detail tests -----------------------------------------------
            EditItem(browser);
            System.Threading.Thread.Sleep(_testStepInterval);

            DeleteItem(browser);
            System.Threading.Thread.Sleep(_testStepInterval);

            //search ----------------------------------------------------------
            AddItem(browser, "Bucket drive item test 1", "Hot");
            System.Threading.Thread.Sleep(_testStepInterval);

            AddItem(browser, "Bucket drive item test 2", "Hot");
            System.Threading.Thread.Sleep(_testStepInterval);

            Search(browser);
            System.Threading.Thread.Sleep(_testStepInterval);

            DeleteItem(browser);
            System.Threading.Thread.Sleep(_testStepInterval);

            //sort ----------------------------------------------------------
            AddSortCategoryTestItems(browser);

            Sort(browser);

            Utilities.CloseBrowser(browser);
        }
コード例 #21
0
 public static void CreateDriver()
 {
     _driver = new RemoteWebDriver(_uri, CreateDesiredCapabilities());
     _driver.Manage().Timeouts().ImplicitlyWait(DefaultImplicitlyWait);
     _driver.Manage().Timeouts().SetScriptTimeout(DefaultScriptTimeout);
 }