Provides a way to use the driver through
Inheritance: IWebDriver, ISearchContext, IJavaScriptExecutor, IFindsById, IFindsByClassName, IFindsByLinkText, IFindsByName, IFindsByTagName, IFindsByXPath, IFindsByPartialLinkText, IFindsByCssSelector, IHasInputDevices, IHasCapabilities, IAllowsFileDetection
Exemple #1
1
        /// <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;
        }
Exemple #2
0
        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;
        }
 public void ShouldBeAbleToCreateRemoteWebDriverWithNoSlashAtEndOfUri()
 {
     Environment.EnvironmentManager.Instance.CloseCurrentDriver();
     RemoteWebDriver noSlashDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:6000/wd/hub"), DesiredCapabilities.InternetExplorer());
     noSlashDriver.Url = javascriptPage;
     noSlashDriver.Quit();
 }
Exemple #4
0
        protected void RunTest(String browserType, String url)
        {
            APP_LOGGER.Debug("Running Test With " + browserType + " on URL " + url);

            // Open Browser
            IWebDriver wd ;

            if (browserType.Equals("firefox"))
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.Firefox());
            else if (browserType.Equals("safari"))
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.Safari());
            else if(browserType.Equals("chrome"))
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.Chrome());
            else
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.InternetExplorer());

            // Go to Google.com
            wd.Url = url;

            Random rnd = new Random();
            int randomSeconds = rnd.Next(1, 11);

            // Wait for Random Time (1s to 10 s)
            APP_LOGGER.DebugFormat("Waiting for {0} seconds Before Exiting Browser", randomSeconds);
            Thread.Sleep(TimeSpan.FromSeconds(randomSeconds));

            // Quit Browser
            wd.Quit();
        }
        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;
            }
        }
 public static void ClickPrimary(RemoteWebDriver driver)
 {
     // Unable to click the Okay button due to chrome driver issue.
     // @see http://code.google.com/p/selenium/issues/detail?id=2766
     // Just run direct JS
     (driver as IJavaScriptExecutor).ExecuteScript("$('.modal-footer .btn-primary').trigger('click')");
 }
Exemple #7
0
        //private static ISelenium selenium;

        
        
        public static void setup()
        {
            
            IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),DesiredCapabilities.HtmlUnit());
                        
            //driver = new FirefoxDriver();
            Selenium.WebDriverBackedSelenium s = new Selenium.WebDriverBackedSelenium(driver, @"http://site4.way2sms.com/content/index.html");
            s.Start();
            driver.Navigate().GoToUrl("http://site4.way2sms.com/content/index.html");
            
            
            WaitForLinkTextPresent(driver, "► click here to go to way2sms.com", 40);
            driver.FindElement(By.Id("username")).SendKeys("9916089888");
            driver.FindElement(By.Id("password")).SendKeys("suprwolf");
            driver.FindElement(By.Id("button")).Click();
            

            if (WaitIdPresent(driver, "quickclose1",40000))
            {
                driver.FindElement(By.Id("quickclose1")).Click();
            }

            driver.FindElement(By.Id("quicksms")).Click();
            driver.SwitchTo().Frame("frame");
            s.WaitForPageToLoad("30000");
            driver.FindElement(By.Id("MobNo")).SendKeys("9916089888");
            WaitIdPresent(driver, "textArea", 400);
            driver.FindElement(By.Id("textArea")).SendKeys("test");

            driver.FindElement(By.Id("Send")).Submit();
            driver.FindElement(By.LinkText("Logout")).Clear();
           
            
        }
Exemple #8
0
 public static void Initialize()
 {
     Instance = new InternetExplorerDriver(new InternetExplorerOptions()
     {
         IntroduceInstabilityByIgnoringProtectedModeSettings = true
     });
 }
		public static IWebDriver Authenticate()
		{
			string email = "admin@test";
			IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());
			//webDriver.Manage().Window.Maximize();
			webDriver.Navigate().GoToUrl("http://dev.icms/Account/Login");
			//Enter email address on login page
			IWebElement emailLogin = webDriver.FindElement(By.Id("Email"));
			emailLogin.Clear();
			emailLogin.SendKeys(email);
			IWebElement authenticateButton = webDriver.FindElement(By.Id("requestauth"));
			authenticateButton.Click();
			//this should have sent me an email
			//Let's pretend we got the email and check the server for the authtoken and plug it into the URL

			string token = HttpUtility.UrlEncode(TestUtilities.AuthenticationUtil.GetAuthToken(email));
			string goToUrl = string.Format("http://dev.icms/account/authorize/?authtoken={0}&email={1}&returnUrl=%2f", token, email);

			webDriver.Quit();
			webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());

			webDriver.Navigate().GoToUrl(goToUrl);

			//Check DOM to see if we are logged in
			IWebElement elem = webDriver.FindElement(By.CssSelector("h1"));
			//webDriver.Quit();
			if (elem.Text == "Welcome Admin Development")
			{
				return webDriver;
			}
			return null;
		}
      public void MyTestInitialize()
      {
         browser = this.TestContext.Properties["browser"] != null ? this.TestContext.Properties["browser"].ToString() : "ie";

         switch (browser)
         {
            case "firefox":
               driver = new FirefoxDriver();
               break;

            case "chrome":
               driver = new ChromeDriver();
               break;

            default:
               driver = new InternetExplorerDriver();
               break;
         }

         // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
         if (this.TestContext.Properties["webAppUrl"] != null)
         {
            this.baseURL = this.TestContext.Properties["webAppUrl"].ToString();
         }
         else
         {
            this.baseURL = "http://peopletrackerdockerhost-dev.westus.cloudapp.azure.com/";
         }
      }
Exemple #11
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Driver"/> class.
        /// </summary>
        /// <param name="browser">Browser name.</param>
        /// <param name="timeout">Implicit time to wait.</param>
        public Driver(string browser, int timeout = 10)
        {
            this.timeout = timeout;

            Log.Debug("Working directory: " + this.directory);
            Log.Debug("Browser: " + browser);
            Log.Debug("Driver timeout: " + timeout);

            switch (browser)
            {
                case "firefox":
                    this.driver = new FirefoxDriver();
                    break;
                case "ie":
                    var ieOptions = new InternetExplorerOptions { EnsureCleanSession = true };
                    this.driver = new InternetExplorerDriver(this.directory, ieOptions);
                    break;
                case "edge":
                    this.driver = new EdgeDriver(this.directory);
                    break;
                case "chrome":
                    this.driver = new ChromeDriver(this.directory);
                    break;
                case "safari":
                    this.driver = new SafariDriver();
                    break;
                default:
                    throw new Exception("Browser name is incorrect.");
            }

            this.driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, timeout));
            this.driver.Manage().Cookies.DeleteAllCookies();
            this.driver.Manage().Window.Maximize();
        }
Exemple #12
0
 private static void FillVendorCredentialForm(RemoteWebDriver browser, string name, string value)
 {
     browser.FindElementByCssSelector("input#CredentialName").Clear();
     browser.FindElementByCssSelector("input#CredentialName").SendKeys(name);
     browser.FindElementByCssSelector("input#CredentialValue").Clear();
     browser.FindElementByCssSelector("input#CredentialValue").SendKeys(value);
 }
        private static IWebDriver GetRemoteWebDriver()
        {
            IWebDriver driver = new RemoteWebDriver(new Uri(Configuration.Instance.Selenium.RemoteGridHub),
                DesiredCapabilities.Chrome());


            return driver;
        }
 public void Setup()
 {
     //ScenarioContext.Current.Pending();
     var path = @"C:\Users\ismaelw\Documents\Visual Studio 2013\Projects\CodedUI-POC\CodedUI-POC\AppPackages\CodedUI-POC_1.0.0.10_x86_Debug_Test\CodedUI-POC_1.0.0.10_x86_Debug.appx";
     var dc = new DesiredCapabilities();
     dc.SetCapability("app", path);
     this.Driver = new WpDriver(new Uri("http://localhost:9999"), dc);
 }
Exemple #15
0
 public void Shutdown()
 {
     if (_driver != null)
     {
         _driver.Quit();
         _driver = null;
     }
 }
Exemple #16
0
 public static void SubmitLoginForm(RemoteWebDriver browser, string email, string password)
 {
     var formSelector = "form[action^='/Account/Login'] ";
     browser.FindElementByCssSelector(formSelector + "input#Email").SendKeys(email);
     browser.FindElementByCssSelector(formSelector + "input#Password").SendKeys(password);
     browser.FindElementByCssSelector(formSelector + "input[value='Log in']").Click();
     WaitUntilUserIsLoggedIn(browser);
 }
 public static void CloseBrowser(RemoteWebDriver browser)
 {
     if (browser != null)
     {
         browser.Close();
         browser.Dispose();
         browser = null;
     }
 }
Exemple #18
0
        public static RemoteWebDriver GetFirefoxServerDriver()
        {
            DesiredCapabilities capability = DesiredCapabilities.Firefox();

            RemoteWebDriver driver = new RemoteWebDriver(
                new Uri(String.Format("http://{0}/wd/hub", Settings.Default.hostnameServer)),
                capability);
            return driver;
        }
Exemple #19
0
        public static bool IsClickable(this OpenQA.Selenium.Remote.RemoteWebDriver driver, IWebElement element)
        {
            if (element != null && element.Displayed && element.Enabled)
            {
                return(true);
            }

            return(false);
        }
Exemple #20
0
 public static void closeBrowser()
 {
     if (WebDriver != null)
     {
         WebDriver.Close();
         WebDriver.Quit();
         WebDriver = null;
         Console.WriteLine("CloseBrowser - the browser has been closed");
     }
 }
Exemple #21
0
        public static void SetValueForChosenJQueryControl(RemoteWebDriver browser, string cssSelector, string value)
        {
            browser.FindElementByCssSelector(cssSelector);  // ensure the form field is present

            //  Click a contained ".chzn-single" element, if available
            var clickTarget = browser.FindElementByCssSelector(cssSelector + " .chzn-single");
            clickTarget.Click();

            browser.FindElementByCssSelector(cssSelector + " input[type=text]").SendKeys(value + Keys.Tab);
        }
Exemple #22
0
 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();
 }
Exemple #23
0
		public static void ShouldPresentLicenseList( RemoteWebDriver driver, AuthenticatingNavigator navigator )
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "" );

				WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromSeconds( 5 ) );
				wait.Until( d => driver.Title.Equals( "Licenses" ) );
			}
		}
        private ITakeScreenShot GetScreenShotImplementer(RemoteWebDriver webDriver)
        {
            var executor = Assembly.GetExecutingAssembly()
                .GetTypes()
                .Where(type => typeof(ITakeScreenShot).IsAssignableFrom(type) && type.IsClass)
                .Select(Activator.CreateInstance)
                .Cast<ITakeScreenShot>();

            return executor.FirstOrDefault(d => d.CanTakeScreenShot(webDriver));
        }
 private static void WaitUnitJavascriptTrue(RemoteWebDriver driver, string javascript)
 {
     Func<IWebDriver, bool> condition = delegate
                                            {
                                                var scriptResult = driver.ExecuteScript(javascript);
                                                var isScriptActive = (bool)scriptResult;
                                                return isScriptActive;
                                            };
     driver.Wait().Until(condition);
 }
        public void Run(string webProjectFolder, int portNumber)
        {
            var webApplication = new WebApplication(ProjectLocation.FromFolder(webProjectFolder), portNumber);
            _webServer = new IisExpressWebServer(webApplication);
            _webServer.Start();
            _webDriver = new FirefoxDriver();
            _webDriver.Navigate().GoToUrl(_webServer.BaseUrl);

            AppDomain.CurrentDomain.DomainUnload += CurrentDomainDomainUnload;
        }
 private void BlockUntilElementIsAvailable(RemoteWebDriver driver, string elementSelector)
 {
     while (true)
     {
         var len = driver.ExecuteScript("return $(\"" + elementSelector + "\").length");
         if (Convert.ToInt32(len) > 0)
             break;
         Thread.Sleep(100);
     }
 }
        protected void DeleteItem(RemoteWebDriver browser)
        {
            IWebElement link = browser.FindElement(By.Id("blAHrefLink0"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("DesktopDeleteButton"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);
        }
        protected void Search(RemoteWebDriver browser)
        {
            browser.FindElement(By.Id("SearchTerm")).SendKeys("drive");
            System.Threading.Thread.Sleep(_testStepInterval);

            IWebElement link = browser.FindElement(By.Id("searchButtonSubmit"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("CancelSearchResultDisplay"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            browser.FindElement(By.Id("SearchTerm")).SendKeys("drive");
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("searchButtonSubmit"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("ProcessEdit0"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("DesktopDeleteButton"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            browser.FindElement(By.Id("SearchTerm")).SendKeys("drive");
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("searchButtonSubmit"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("ProcessEdit0"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("DesktopEditButton"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);

            browser.FindElement(By.Id("BIItemName")).SendKeys(" edited item value");
            System.Threading.Thread.Sleep(_testStepInterval);

            IWebElement rankingItemSelect = browser.FindElement(By.Name("rankingItemSelect"));
            SelectElement selectElement = new SelectElement(rankingItemSelect);
            selectElement.SelectByText("Warm");
            System.Threading.Thread.Sleep(_testStepInterval);

            link = browser.FindElement(By.Id("EditBIButtonSubmit"));
            link.Click();
            System.Threading.Thread.Sleep(_testStepInterval);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (Driver != null)
         {
             Driver.Quit();
             Driver = null;
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteTouchScreen"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="RemoteWebDriver"/> for which the touch screen will be managed.</param>
 public RemoteTouchScreen(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderedRemoteWebElement"/> class.
 /// </summary>
 /// <param name="parent">The <see cref="RemoteWebDriver"/> instance hosting this element.</param>
 /// <param name="id">The ID assigned to the element.</param>
 public RenderedRemoteWebElement(RemoteWebDriver parent, string id)
     : base(parent, id)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteCookieJar"/> class.
 /// </summary>
 /// <param name="driver">The driver that is currently in use</param>
 public RemoteCookieJar(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
 /// <summary>
 /// Initializes a new instance of the RemoteNavigator class
 /// </summary>
 /// <param name="driver">Driver in use</param>
 public RemoteNavigator(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteLocationContext"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="RemoteWebDriver"/> for which the application cache will be managed.</param>
 public RemoteLocationContext(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteApplicationCache"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="RemoteWebDriver"/> for which the application cache will be managed.</param>
 public RemoteApplicationCache(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #37
0
 public RemoteSessionStorage(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #38
0
 /// <summary>
 /// Initializes a new instance of the RemoteOptions class
 /// </summary>
 /// <param name="driver">Instance of the driver currently in use</param>
 public RemoteOptions(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteMouse"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="RemoteWebDriver"/> for which the mouse will be managed.</param>
 public RemoteMouse(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteKeyboard"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="RemoteWebDriver"/> for which the keyboard will be managed.</param>
 public RemoteKeyboard(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteWindow"/> class.
 /// </summary>
 /// <param name="driver">Instance of the driver currently in use</param>
 public RemoteWindow(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteTimeouts"/> class
 /// </summary>
 /// <param name="driver">The driver that is currently in use</param>
 public RemoteTimeouts(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #43
0
 /// <summary>
 /// Finds the first element in the page that matches the CSS Class supplied
 /// </summary>
 /// <param name="className">CSS class name of the element on the page</param>
 /// <returns>IWebElement object so that you can interact that object</returns>
 /// <example>
 /// <code>
 /// IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.Firefox());
 /// IWebElement elem = driver.FindElementByClassName("classname")
 /// </code>
 /// </example>
 public virtual IWebElement FindElementByClassName(string className)
 {
     return(this.FindElement("css selector", "." + RemoteWebDriver.EscapeCssSelector(className)));
 }
Exemple #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteWebElement"/> class.
 /// </summary>
 /// <param name="parentDriver">The <see cref="RemoteWebDriver"/> instance hosting this element.</param>
 /// <param name="id">The ID assigned to the element.</param>
 public RemoteWebElement(RemoteWebDriver parentDriver, string id)
 {
     this.driver    = parentDriver;
     this.elementId = id;
 }
Exemple #45
0
 /// <summary>
 /// Finds the first element in the page that matches the ID supplied
 /// </summary>
 /// <param name="id">ID of the Element</param>
 /// <returns>ReadOnlyCollection of Elements that match the object so that you can interact that object</returns>
 /// <example>
 /// <code>
 /// IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.Firefox());
 /// ReadOnlyCollection<![CDATA[<IWebElement>]]> elem = driver.FindElementsById("id")
 /// </code>
 /// </example>
 public virtual ReadOnlyCollection <IWebElement> FindElementsById(string id)
 {
     return(this.FindElements("css selector", "#" + RemoteWebDriver.EscapeCssSelector(id)));
 }
Exemple #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteAlert"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="RemoteWebDriver"/> for which the alerts will be managed.</param>
 public RemoteAlert(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #47
0
 /// <summary>
 /// Finds a list of elements that match the class name supplied
 /// </summary>
 /// <param name="className">CSS class name of the elements on the page</param>
 /// <returns>ReadOnlyCollection of IWebElement object so that you can interact with those objects</returns>
 /// <example>
 /// <code>
 /// IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.Firefox());
 /// ReadOnlyCollection<![CDATA[<IWebElement>]]> elem = driver.FindElementsByClassName("classname")
 /// </code>
 /// </example>
 public virtual ReadOnlyCollection <IWebElement> FindElementsByClassName(string className)
 {
     return(this.FindElements("css selector", "." + RemoteWebDriver.EscapeCssSelector(className)));
 }
Exemple #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteTargetLocator"/> class
 /// </summary>
 /// <param name="driver">The driver that is currently in use</param>
 public RemoteTargetLocator(RemoteWebDriver driver)
 {
     this.driver = driver;
 }
Exemple #49
0
 /// <summary>
 /// Finds the first element in the page that matches the ID supplied
 /// </summary>
 /// <param name="id">ID of the element</param>
 /// <returns>IWebElement object so that you can interact with that object</returns>
 /// <example>
 /// <code>
 /// IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.Firefox());
 /// IWebElement elem = driver.FindElementById("id")
 /// </code>
 /// </example>
 public virtual IWebElement FindElementById(string id)
 {
     return(this.FindElement("css selector", "#" + RemoteWebDriver.EscapeCssSelector(id)));
 }
Exemple #50
-4
    public static IWebDriver Create(string browser)
    {
        DesiredCapabilities capabilities;
        IWebDriver driver;

        switch (browser) {
            case "chrome":
                capabilities = DesiredCapabilities.Chrome();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
                break;
            case "internet explorer":
                InternetExplorerOptions options = new InternetExplorerOptions();
                options.IgnoreZoomLevel = true;
                capabilities = (DesiredCapabilities)options.ToCapabilities();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities, TimeSpan.FromSeconds(10));
                break;
            case "edge":
                capabilities = DesiredCapabilities.Edge();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
                break;
            default:
                capabilities = DesiredCapabilities.Firefox();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
                break;
        }

        return driver;
    }