Inheritance: ISeleniumWrapper
コード例 #1
0
        private static ElementWrapper UploadFileByDiv(ElementWrapper element, string fullFileName)
        {
            element.BrowserWrapper.GetJavaScriptExecutor()
               .ExecuteScript("dotvvm.fileUpload.createUploadId(arguments[0])", element.First("a", SelectBy.CssSelector).WebElement);

            var iframe = element.First("iframe", SelectBy.CssSelector);
            element.BrowserWrapper.Browser.SwitchTo().Frame(iframe.WebElement);

            var fileInput = element.BrowserWrapper._GetInternalWebDriver()
                .FindElement(SelectBy.CssSelector("input[type=file]"));
            fileInput.SendKeys(fullFileName);

            element.Wait(element.ActionWaitTime);
            element.ActivateScope();
            return element;
        }
コード例 #2
0
 /// <summary>
 /// Opens file dialog and sends keys with full path to file, that should be uploaded.
 /// </summary>
 /// <param name="fileUploadOpener">Element that opens file dialog after it is clicked.</param>
 /// <param name="fullFileName">Full path to file that is intended to be uploaded.</param>
 public virtual BrowserWrapper FileUploadDialogSelect(ElementWrapper fileUploadOpener, string fullFileName)
 {
     if (fileUploadOpener.GetTagName() == "input" && fileUploadOpener.HasAttribute("type") && fileUploadOpener.GetAttribute("type") == "file")
     {
         fileUploadOpener.SendKeys(fullFileName);
         Wait();
     }
     else
     {
         // open file dialog
         fileUploadOpener.Click();
         Wait();
         //Another wait is needed because without it sometimes few chars from file path are skipped.
         Wait(1000);
         // write the full path to the dialog
         System.Windows.Forms.SendKeys.SendWait(fullFileName);
         Wait();
         SendEnterKey();
     }
     return(this);
 }
コード例 #3
0
ファイル: Extensions.cs プロジェクト: riganti/selenium-utils
 public static ElementWrapperCollection ToElementsList(this IEnumerable<IWebElement> elements, BrowserWrapper browserWrapper, string selector, ElementWrapper elementWrapper)
 {
     return new ElementWrapperCollection(elements.Select(s => new ElementWrapper(s, browserWrapper)), selector, elementWrapper, browserWrapper);
 }
コード例 #4
0
 public void ElementWaitForTimeoutTest4()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     var element = new ElementWrapper(new MockIWebElement(), browser);
     var i = 0;
     element.WaitFor(elm => i++ == 5, 2000, "test timeouted", checkInterval: 100);
 }
コード例 #5
0
 public void ElementWaitForTimeoutTest()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     var element = new ElementWrapper(new MockIWebElement(), browser);
     element.WaitFor(elm => false, 2000, "test timeouted");
 }
コード例 #6
0
        public void ElementWaitForTimeoutTest6()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
            var element = new ElementWrapper(new MockIWebElement(), browser);
            var i = 0;
            element.WaitFor((elm) =>
            {

                if (i++ == 3)
                {
                    return;
                }
                throw new Exception("Not valid.");
            }, 2000, "test timeouted", checkInterval: 100);
        }
コード例 #7
0
 public void ElementWaitForTimeoutTest5()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     var element = new ElementWrapper(new MockIWebElement(), browser);
     var i = 0;
     element.WaitFor((elm) => elm.CheckIfValue("asdasdasdasd"), 2000, "test timeouted", checkInterval: 100);
 }
コード例 #8
0
 public static ElementWrapperCollection ToElementsList(this IEnumerable <IWebElement> elements, BrowserWrapper browserWrapper, string selector, ElementWrapper elementWrapper)
 {
     return(new ElementWrapperCollection(elements.Select(s => new ElementWrapper(s, browserWrapper)), selector, elementWrapper, browserWrapper));
 }