コード例 #1
1
ファイル: Program.cs プロジェクト: rpereda/Test
 //[SetUp]
 public void SetupTest(IWebDriver driverp)
 {
     //driver = new ChromeDriver();
     //TODO: We can iterate drivers
     driver = driverp;
     //TODO: We can read the server from config file or table
     baseURL = "http://ebgdev03:81";
     verificationErrors = new StringBuilder();
     wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(timeout));
     //Logs directories
     if (!System.IO.Directory.Exists(imageLogsDirectory))
         System.IO.Directory.CreateDirectory(imageLogsDirectory);
 }
コード例 #2
1
ファイル: WaitUtils.cs プロジェクト: CodenameLiam/Lactalis
 public static void waitForPage(IWait <IWebDriver> wait, string url)
 {
     wait.Until(d => d.Url == url);
     waitForPage(wait);
 }
コード例 #3
0
ファイル: Exceptions.cs プロジェクト: Charlp/BotBuilder
 protected InvalidWaitException(string message, IWait wait)
     : base(message)
 {
     SetField.NotNull(out this.wait, nameof(wait), wait);
 }
コード例 #4
0
ファイル: Exceptions.cs プロジェクト: Charlp/BotBuilder
 public InvalidTypeException(IWait wait, Type type)
     : base($"invalid type: expected {wait.ItemType}, have {type.Name}", wait)
 {
     SetField.NotNull(out this.type, nameof(type), type);
 }
コード例 #5
0
ファイル: Exceptions.cs プロジェクト: Charlp/BotBuilder
 public InvalidNextException(IWait wait)
     : base($"invalid next: {wait}", wait)
 {
 }
コード例 #6
0
ファイル: ProductPage.cs プロジェクト: IgorDodukh/TestProject
 public ProductPage(IWebDriver driver)
 {
     this.driver = driver;
     wait        = new WebDriverWait(this.driver, TimeSpan.FromSeconds(10));
 }
コード例 #7
0
 public Objects(IWebDriver driver, BrowserInit browser)
 {
     this.driver = driver;
     this.iWait  = browser.iWait;
 }
コード例 #8
0
ファイル: DomContainer.cs プロジェクト: pusp/o2platform
		/// <summary>
		/// Waits for the page to be completely loaded
		/// </summary>
		/// <param name="waitForComplete">The wait for complete.</param>
		public void WaitForComplete(IWait waitForComplete)
		{
			waitForComplete.DoWait();
		}
コード例 #9
0
 public TicketRetriever(IWait wait, IZendeskApi zendeskApi, Func<DateTime> utcNowProvider = null)
 {
     _wait = wait;
     _zendeskApi = zendeskApi;
     _utcNowProvider = utcNowProvider ?? (() => DateTime.UtcNow);
 }
コード例 #10
0
ファイル: Wait.cs プロジェクト: whlizhongming2009/BotBuilder
        public override string ToString()
        {
            IWait wait = this;

            return($"Wait: {wait.Need} {wait.NeedType?.Name} for {this.rest?.Target.GetType().Name}.{this.rest?.Method.Name} have {wait.ItemType?.Name} {this.item}");
        }
コード例 #11
0
 void IDialogStack.Fail(Exception error)
 {
     this.wait = this.fiber.Fail(error);
 }
コード例 #12
0
 /// <summary>
 /// Waits for the page to be completely loaded
 /// </summary>
 /// <param name="waitForComplete">The wait for complete.</param>
 public void WaitForComplete(IWait waitForComplete)
 {
     waitForComplete.DoWait();
 }
コード例 #13
0
        public Chrome_BuyVideoVerification(IWebDriver driver, ILog log1, IJavaScriptExecutor Executor, IWait <IWebDriver> iWait)
        {
            this.driver = driver;

            log = log1;

            this.executor = Executor;

            this.iWait = iWait;
        }
コード例 #14
0
 public WebDriver(LoggerClass log)
 {
     Driver = new ChromeDriver();
     _wait  = new WebDriverWait(Driver, TimeSpan.FromSeconds(_waitTimeout));
     _log   = log;
 }
コード例 #15
0
 public Chrome_QAManagement(IWebDriver driver, ILog log1, IJavaScriptExecutor Executor, IWait <IWebDriver> iWait)
 {
     this.driver   = driver;
     log           = log1;
     this.executor = Executor;
     this.iWait    = iWait;
 }
コード例 #16
0
 public static IWait <C> CloneTyped <C>(this IWait <C> wait)
 {
     return((IWait <C>)wait.Clone());
 }
コード例 #17
0
        public BrowserInit()
        {
            try
            {
                string rootPath = AppDomain.CurrentDomain.BaseDirectory;

                //string rootPath = Environment.CurrentDirectory;

                //string rootPath = @"D:\workspace\FTC\FTC\FTC.Framework\bin\Debug";


                //System.Environment.SetEnvironmentVariable(driverName, driverPath);

                if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.firefox.ToString(), "Browser.xml")) == true)
                {
                    driver = new FirefoxDriver();

                    Current.BrowserName = BrowserCollection.firefox.ToString();

                    screenHeight = Helper.GetScreenHeight(driver);

                    screenWidth = Helper.GetScreenWidth(driver);

                    Helper.SetWindowPosition(driver, 0, 0);

                    Helper.SetWindowSize(driver, screenWidth, screenHeight);
                }
                else if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.chrome.ToString(), "Browser.xml")) == true)
                {
                    driverName = "webdriver.chrome.driver";

                    //  driverPath = rootPath + "\\chromedriver.exe";

                    System.Environment.SetEnvironmentVariable(driverName, driverPath);
                    // driverPath = rootPath+"\\Library\\";
                    // driverName = "webdriver.chrome.driver";

                    ChromeOptions options = new ChromeOptions();
                    //options.AddArgument("--disable-extensions");
                    driver = new ChromeDriver(rootPath, options);

                    Current.BrowserName = BrowserCollection.chrome.ToString();


                    screenHeight = Helper.GetScreenHeight(driver);

                    screenWidth = Helper.GetScreenWidth(driver);

                    Helper.SetWindowPosition(driver, 0, 0);

                    Helper.SetWindowSize(driver, screenWidth, screenHeight);

                    Console.WriteLine("Is Driver null :: " + (driver == null));
                }
                else if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.ie.ToString(), "Browser.xml")) == true)
                {
                    InternetExplorerOptions options = new InternetExplorerOptions();
                    options.EnsureCleanSession = true;
                    options.EnableNativeEvents = true;
                    options.IgnoreZoomLevel    = true;
                    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                    driverName = "webdriver.ie.driver";
                    driverPath = rootPath + "/IEDriverServer.exe";

                    driver       = new InternetExplorerDriver(options);
                    screenHeight = Helper.GetScreenHeight(driver);

                    screenWidth = Helper.GetScreenWidth(driver);

                    Helper.SetWindowPosition(driver, 0, 0);

                    Helper.SetWindowSize(driver, screenWidth, screenHeight);

                    Current.BrowserName = BrowserCollection.ie.ToString();

                    // Add code to add Registry in IE 11
                    Current.IEVersion = Helper.GetIEVersion(driver, driver.FindElement(By.TagName("html")));

                    if (Current.IEVersion.Equals("IE11"))
                    {
                        Helper.CheckIE11RegistryPresence();
                    }
                }
                else if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.phantom.ToString(), "Browser.xml")) == true)
                {
                    driver = new PhantomJSDriver();

                    Current.BrowserName = BrowserCollection.phantom.ToString();

                    screenHeight = Helper.GetScreenHeight(driver);

                    screenWidth = Helper.GetScreenWidth(driver);

                    Helper.SetWindowPosition(driver, 0, 0);

                    Helper.SetWindowSize(driver, screenWidth, screenHeight);
                }
                else
                {
                    throw new NoBrowserSelectedException();
                }


                iWait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(150.00));
            }
            catch (NoBrowserSelectedException ex)
            {
                Logger.log.Error("Error In Browser Selection.");
                Logger.log.Error(ex);
            }
            catch (Exception ex)
            {
                Logger.log.Error("Error In Browser Initialization.");
                Logger.log.Error(ex);
            }
        }
コード例 #18
0
 /// <summary>
 ///     Wait until element is actually displayed in the DOM
 /// </summary>
 /// <param name="wait"></param>
 /// <param name="webElement"></param>
 public static void WaitForWebElementDisplayed(IWait <IWebDriver> wait, IWebElement webElement)
 {
     wait.Until(x => webElement.Displayed);
 }
コード例 #19
0
 /// <summary>
 ///     Wait until element is enabled
 /// </summary>
 /// <param name="wait"></param>
 /// <param name="webElement"></param>
 public static void WaitForWebElementEnabled(IWait <IWebDriver> wait, IWebElement webElement)
 {
     wait.Until(x => webElement.Enabled);
 }
コード例 #20
0
 private void Wait_Free(IWait sender)
 {
     waits.Where(x => x.Item1.Equals(sender)).FirstOrDefault()?.Item2.Set();
 }
コード例 #21
0
ファイル: WaitUtils.cs プロジェクト: CodenameLiam/Lactalis
 public static void waitForPage(IWait <IWebDriver> wait)
 {
     wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
 }
コード例 #22
0
ファイル: WaitUtils.cs プロジェクト: CodenameLiam/Lactalis
        private static void waitForElement(IWait <IWebDriver> wait, IWebElement parentElement, By elementPath, ElementState status)
        {
            switch (status)
            {
            case ElementState.VISIBLE:
                wait.Until(driver =>
                {
                    try
                    {
                        return(parentElement != null
                                                                ? parentElement.FindElement(elementPath).Displayed
                                                                : driver.FindElement(elementPath).Displayed);
                    }
                    catch (NoSuchElementException)
                    {
                        return(false);
                    }
                });
                break;

            case ElementState.NOT_VISIBLE:
                wait.Until(driver =>
                {
                    try
                    {
                        return(parentElement != null
                                                                ? !parentElement.FindElement(elementPath).Displayed
                                                                : !driver.FindElement(elementPath).Displayed);
                    }
                    catch (NoSuchElementException)
                    {
                        return(true);
                    }
                });
                break;

            case ElementState.EXISTS:
                wait.Until(driver =>
                {
                    try
                    {
                        var element = parentElement != null
                                                                ? parentElement.FindElement(elementPath)
                                                                : driver.FindElement(elementPath);

                        return(true);
                    }
                    catch (NoSuchElementException)
                    {
                        return(false);
                    }
                });
                break;

            case ElementState.NOT_EXIST:
                wait.Until(driver =>
                {
                    try
                    {
                        var element = parentElement != null
                                                                ? parentElement.FindElement(elementPath)
                                                                : driver.FindElement(elementPath);

                        return(false);
                    }
                    catch (NoSuchElementException)
                    {
                        return(true);
                    }
                });
                break;

            default:
                throw new Exception($" '{status}' is not a valid status to wait for element");
            }
        }
コード例 #23
0
ファイル: WaitUtils.cs プロジェクト: CodenameLiam/Lactalis
 /// <summary>
 /// A wait util method to use when waiting for an element to be in a state
 /// </summary>
 /// <param name="wait">The preconfigured driver wait to use</param>
 /// <param name="parentElement">the parent of the element to wait for</param>
 /// <param name="elementPath">The OpenQA.Selenium.By used to locate the element</param>
 /// <param name="status">visible, not visible, exist, not exist</param>
 /// <returns> a boolean indicating if the expected status is true or false</returns>
 public static bool elementState(IWait <IWebDriver> wait, IWebElement parentElement, By elementPath, ElementState status) =>
 waitForElementRunner(wait, parentElement, elementPath, status);
コード例 #24
0
 public Objects(IWebDriver driver, IWait <IWebDriver> wait)
 {
     this.driver = driver;
     this.wait   = wait;
 }
コード例 #25
0
 public InvalidNeedException(IWait wait, Need need)
     : base($"invalid need: expected {need}, have {wait.Need}", wait)
 {
     this.need = need;
     this.have = wait.Need;
 }
コード例 #26
0
 public BookDetailsPage(IWebDriver driver, IWait <IWebDriver> wait) : base(driver, wait)
 {
 }
コード例 #27
0
        public WebDriver(string driverType, LoggerClass log)
        {
            _log = log;
            if (ConfigurationManager.AppSettings.Get("Grid") == "true")
            {
                DesiredCapabilities capabilities = new DesiredCapabilities();
                switch (driverType)
                {
                case "Firefox":
                    capabilities = DesiredCapabilities.Firefox();
                    capabilities.SetCapability(CapabilityType.BrowserName, "firefox");
                    _log.Log("Start Webdriver grid firefox");
                    break;

                case "IE":
                    capabilities = DesiredCapabilities.InternetExplorer();
                    capabilities.SetCapability(CapabilityType.BrowserName, "internet explorer");
                    _log.Log("Start Webdriver grid internet explorer");
                    break;

                case "Chrome":
                    capabilities = DesiredCapabilities.Chrome();
                    capabilities.SetCapability(CapabilityType.BrowserName, "chrome");
                    _log.Log("Start Webdriver grid chrome");
                    break;

                default:
                    capabilities = DesiredCapabilities.Chrome();
                    capabilities.SetCapability(CapabilityType.BrowserName, "chrome");
                    _log.Log("Start Webdriver grid default chrome");
                    break;
                }
                switch (ConfigurationManager.AppSettings.Get("PlatformType"))
                {
                case "Windows":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
                    _log.Log("Platform grid Windows");
                    break;

                case "Linux":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Linux));
                    _log.Log("Platform grid Linux");
                    break;

                case "Mac":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Mac));
                    _log.Log("Platform grid Mac");
                    break;

                case "Unix":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Unix));
                    _log.Log("Platform grid Unix");
                    break;

                case "XP":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.XP));
                    _log.Log("Platform grid XP");
                    break;

                default:
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
                    _log.Log("Platform grid default Windows");
                    break;
                }

                capabilities.SetCapability("marionette", true);
                Driver = new RemoteWebDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("localhost") + ":" + ConfigurationManager.AppSettings.Get("port") + "/wd/hub"), capabilities);
                _log.Log("Grid Server" + "http://" + ConfigurationManager.AppSettings.Get("localhost") + ":" + ConfigurationManager.AppSettings.Get("port") + "/wd/hub");
            }
            else
            {
                switch (driverType)
                {
                case "Firefox":
                    Driver = new FirefoxDriver();
                    _log.Log("Start firefox webdriver");
                    break;

                case "IE":
                    Driver = new InternetExplorerDriver();
                    _log.Log("Start internet explorer webdriver");
                    break;

                case "Chrome":
                    Driver = new ChromeDriver();
                    _log.Log("Start Chrome webdriver");
                    break;

                default:
                    Driver = new ChromeDriver();
                    _log.Log("Start default Chrome webdriver");
                    break;
                }
            }

            _wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(_waitTimeout));
            Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
        }
コード例 #28
0
 public WaitTests()
 {
     _log = Mock.Of<ILog>();
     _sut = new Wait(_log);
 }
コード例 #29
0
 private void AddTimeouts()
 {
     WebDriver.Manage().Window.Maximize();
     WebDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(configuration.Timeout);
     Wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(30.00));
 }
コード例 #30
0
ファイル: Extensions.cs プロジェクト: zhiliangxu/TestEasy
 /// <summary>
 ///     Wait until element is enabled
 /// </summary>
 /// <param name="wait"></param>
 /// <param name="webElement"></param>
 public static void WaitForWebElementEnabled(IWait<IWebDriver> wait, IWebElement webElement)
 {
     wait.Until(x => webElement.Enabled);
 }
コード例 #31
0
 public HomePage(IWebDriver driver, IWait <IWebDriver> wait) : base(driver, wait)
 {
     this.header = new HeaderSection(driver, wait);
     this.footer = new FooterSection(driver, wait);
 }
コード例 #32
0
 public CustomWebDriver() : base()
 {
     this.Wait = new WebDriverWait(this, new TimeSpan(0, 0, 40));
     this.Manage().Window.Maximize();
 }
コード例 #33
0
 public SiteNavigator(IWebDriver webDriver)
 {
     _driver      = webDriver;
     _wait        = new WebDriverWait(_driver, TimeSpan.FromSeconds(20));
     _currentPage = new HomePage(webDriver);
 }
コード例 #34
0
 public InvalidTypeException(IWait wait, Type type)
     : base($"invalid type: expected {wait.ItemType}, have {type.Name}", wait)
 {
     SetField.NotNull(out this.type, nameof(type), type);
 }
コード例 #35
0
 void IDialogStack.Done <R>(R value)
 {
     this.wait = this.fiber.Done(value);
 }
コード例 #36
0
 public InvalidNextException(IWait wait)
     : base($"invalid next: {wait}", wait)
 {
 }
コード例 #37
0
 void IDialogStack.Wait <R>(ResumeAfter <R> resume)
 {
     this.wait = this.fiber.Wait <DialogTask, R>(ToRest(resume));
 }
コード例 #38
0
 protected InvalidWaitException(string message, IWait wait)
     : base(message)
 {
     SetField.NotNull(out this.wait, nameof(wait), wait);
 }
コード例 #39
0
ファイル: Extensions.cs プロジェクト: zhiliangxu/TestEasy
 /// <summary>
 ///     Wait until element is actually displayed in the DOM
 /// </summary>
 /// <param name="wait"></param>
 /// <param name="webElement"></param>
 public static void WaitForWebElementDisplayed(IWait<IWebDriver> wait, IWebElement webElement)
 {
     wait.Until(x => webElement.Displayed);
 }
コード例 #40
-1
        public TicketRetrieverTests()
        {
            _wait = Mock.Of<IWait>();
            _zendeskApi = Mock.Of<IZendeskApi>();
            _utcNowProvider = Mock.Of<Func<DateTime>>();
            _sut = new TicketRetriever(_wait, _zendeskApi, _utcNowProvider);

            SetupDefaultMocks();
        }
コード例 #41
-1
ファイル: Exceptions.cs プロジェクト: Charlp/BotBuilder
 public InvalidNeedException(IWait wait, Need need)
     : base($"invalid need: expected {need}, have {wait.Need}", wait)
 {
     this.need = need;
     this.have = wait.Need;
 }