当前位置: 首页>>代码示例>>C#>>正文


C# this.Click方法代码示例

本文整理汇总了C#中this.Click方法的典型用法代码示例。如果您正苦于以下问题:C# this.Click方法的具体用法?C# this.Click怎么用?C# this.Click使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.Click方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckTheCheckbox

 public static void CheckTheCheckbox(this IWebElement element, bool isWantChecked)
 {
     if (isWantChecked)
     {
         if (!element.Selected)
             element.Click();
     }
     else
     {
         if (element.Selected)
             element.Click();
     }
 }
开发者ID:dnamartin,项目名称:Automation,代码行数:13,代码来源:Extensions.cs

示例2: ClickAndWait

 public static void ClickAndWait(this IWebElement element, double timeoutInSeconds)
 {
     if (!(timeoutInSeconds > 0)) return;
     var timeout = timeoutInSeconds * 1000;
     element.Click();
     Thread.Sleep(Convert.ToInt32(timeout));
 }
开发者ID:tgkuzma,项目名称:TestingDemo,代码行数:7,代码来源:ClickExtensitons.cs

示例3: ClickLink

        public static void ClickLink(this IWebElement link)
        {
            if (link == null)
                throw new ArgumentNullException("link");

            bool exceptionCaught;
            do
            {
                exceptionCaught = false;
                try
                {
                    // sometimes, clicking a button or hyperlink does not work in IE / Chrome
                    // solution is to click only for FF, and use enter key for IE / Chrome
                    if (link.Browser().IsInternetExplorer() || link.Browser().IsFirefox())
                    {
                        link.SendKeys(Keys.Enter);
                    }
                    else
                    {
                        link.Click();
                    }
                }
                catch (WebDriverException)
                {
                    exceptionCaught = true;
                }
            } while (exceptionCaught);
        }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:28,代码来源:WebElementExtensions.cs

示例4: ClickButton

        public static void ClickButton(this IWebElement button)
        {
            if (button == null)
                throw new ArgumentNullException("button");

            bool exceptionCaught;
            do
            {
                exceptionCaught = false;
                try
                {
                    // sometimes, clicking a button or hyperlink does not work in IE / Chrome
                    // solution is to click only for FF, and use enter key for IE / Chrome
                    if (!button.Browser().IsInternetExplorer())
                    {
                        200.WaitThisManyMilleseconds();
                        button.Click();
                    }
                    else
                    {
                        button.SendKeys(Keys.Enter);
                    }
                }
                catch (WebDriverException)
                {
                    exceptionCaught = true;
                }
            } while (exceptionCaught);
        }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:29,代码来源:WebElementExtensions.cs

示例5: ClickAndWait

 public static IWebElement ClickAndWait(this IWebElement element, TimeSpan? time = null)
 {
     time = time ?? TimeSpan.FromSeconds(1);
     element.Click();
     Thread.Sleep(time.Value);
     return element;
 }
开发者ID:mateusleonardi,项目名称:SpecFlowNUnitSelenium,代码行数:7,代码来源:SeleniumExtensions.cs

示例6: WaitUntilElementBecomeClickableAndClick

 public static void WaitUntilElementBecomeClickableAndClick(this IWebElement element)
 {
     var driver = TestEnvironment.Instance.WebDriver;
     var wait = new WebDriverWait(driver, new TimeSpan(0, 0, TestEnvironment.Instance.WaitLongRequestTimeout));
     wait.Until(ExpectedConditions.ElementToBeClickable(element));
     element.Click();
 }
开发者ID:OlhaYeremenko1,项目名称:FacebookTestNet,代码行数:7,代码来源:WaitExtensions.cs

示例7: ClickLink

 /// <summary>
 /// Clicks the link.
 /// </summary>
 /// <param name="me">Me.</param>
 /// <param name="subDomain">Sub domain.</param>
 static void ClickLink(this IWebElement me, string subDomain = null, bool addParams = false)
 {
     //
     // We check the href on me and modify it before clicking (ie. www.google.com -> stage.google.com).
     //
     string href = me.GetAttribute("href");
     Console.WriteLine("ClickLink before '{0}'", href);
     if (subDomain != null) {                
         if (href != null) {
             Uri uri = new Uri(href);
             string oldSubDomain = uri.Host.Split('.')[0];
             string[] notReplaceSubDomains = new string[] { "secure" };
             if (!href.Contains("#") && !(oldSubDomain.Equals(subDomain)) && !notReplaceSubDomains.Contains(oldSubDomain)) {
                 Console.WriteLine("Replacing subdomain '{0}' with '{1}'", oldSubDomain, subDomain);
                 string newHref = href.Replace(oldSubDomain, subDomain);
                 if (addParams) {                            
                     newHref = HttpExtensions.AddQuery(newHref, "param", "value");
                 }
                 IWebDriver driver = Factory.Instance;
                 IJavaScriptExecutor js = ((IJavaScriptExecutor)Factory.Instance);
                 js.ExecuteScript("arguments[0].setAttribute(arguments[1], arguments[2]);", me, "href", newHref);
             }
         }
     }
     href = me.GetAttribute("href");
     Console.WriteLine("ClickLink after '{0}'", href);
     me.Click();
 }
开发者ID:buonan,项目名称:SeleniumTests,代码行数:33,代码来源:Extensions.cs

示例8: click

 public static void click(this IWebElement field)
 {
     if (!field.Enabled && !field.Displayed)
     {
         throw new ElementNotVisibleException("The element passed is not displayed/enabled");
     }
     field.Click();
 }
开发者ID:bizfitechtestteam,项目名称:jack-dev-area,代码行数:8,代码来源:Extensions.cs

示例9: LogOn

 public static void LogOn(this INativeActionSyntaxProvider I, string userName, string password)
 {
     I.Open(UrlHelper.BaseUrl + "users/account/LogOn");
     I.Expect.Url(x => x.LocalPath.Contains("LogOn"));
     I.Enter(EnvironmentSettings.TestAccountName).In("#SignIn_UserNameOrEmail");
     I.Enter(EnvironmentSettings.TestAccountPassword).In("#SignIn_Password");
     I.Click("#signin-link");
 }
开发者ID:segilbert,项目名称:NuGetGallery,代码行数:8,代码来源:ExtensionMethods.cs

示例10: click

 public static Link click(this Link link, int miliseconds)
 {
     if (link != null)
     {
         link.Click();
         miliseconds.sleep();    			
     }
     return link;
 }
开发者ID:modulexcite,项目名称:FluentSharp_Fork.WatiN,代码行数:9,代码来源:WatiN_IE_ExtensionMethods_Link.cs

示例11: BrowserSpecificCheck

 public static IWebElement BrowserSpecificCheck(this IWebElement element, IWebDriver webDriver) {
     if (webDriver is InternetExplorerDriver) {
         element.SendKeys(Keys.Space);
     }
     else {
         element.Click();
     }
     return element;
 }
开发者ID:Robin--,项目名称:NakedObjectsFramework,代码行数:9,代码来源:SeHelpers.cs

示例12: ClickSubMenu

        /// <summary>
        /// Uses jquery to trigger a mouseover event.  Then clicks the submenu link.
        /// </summary>
        /// <param name="cssLocator">Css locator of the parent menu.</param>
        public static void ClickSubMenu(this IWebElement element, string cssLocator)
        {
            var script = String.Format(@"$('{0}').trigger('mouseover');", cssLocator);
            IJavaScriptExecutor js = (IJavaScriptExecutor)Browser.Driver;

            js.ExecuteScript(script);
            element.Click();
            script = String.Format(@"$('{0}').trigger('mouseout');", cssLocator);
            js.ExecuteScript(script);
        }
开发者ID:dnamartin,项目名称:Automation,代码行数:14,代码来源:Extensions.cs

示例13: UploadPackageUsingUI

        public static void UploadPackageUsingUI(this INativeActionSyntaxProvider I, string fullPackagePath)
        {
            // Navigate to the Upload Package page.  This will fail if the user never uploaded the previous package, hence the error handling.
            I.Open(String.Format(UrlHelper.UploadPageUrl));
            try
            {
                I.Expect.Url(x => x.AbsoluteUri.Contains("/packages/Upload"));
            }
            catch
            {
                I.Click("a[class='cancel']");
            }

            // Upload the package.
            I.Click("input[name='UploadFile']");
            I.Wait(5);
            I.Type(fullPackagePath);
            I.Press("{ENTER}");
            I.Wait(5);
            I.Click("input[value='Upload']");
        }
开发者ID:segilbert,项目名称:NuGetGallery,代码行数:21,代码来源:ExtensionMethods.cs

示例14: ClickUsingMouse

 /// <summary>
 /// Click on the element using Actions API. 'Click' method is known to not work in same strange cases on Edge,
 /// Use this method instead
 /// </summary>
 public static void ClickUsingMouse(this IWebElement element, IWebDriver driver)
 {
     ICapabilities capabilities = ((RemoteWebDriver) driver).Capabilities;
     if (capabilities.BrowserName == "Firefox")
     {
         element.Click();
     }
     else
     {
         new Actions(driver).Click(element).Build().Perform();
             //does not work with Firefox 48, Selenium 3.0.0-beta2, GeckoDriver.exe 0.10.0
     }
 }
开发者ID:StarcounterSamples,项目名称:KitchenSink,代码行数:17,代码来源:SeleniumExtensions.cs

示例15: CostCenterComboBoxSelector

 public static void CostCenterComboBoxSelector(this ComboBox comboBox, string elementToSelect)
 {
     if (comboBox != null)
     {
         comboBox.Click();
         comboBox.Select(elementToSelect);
         Console.WriteLine(elementToSelect + " Selected");
     }
     else
     {
         Console.WriteLine(elementToSelect + " not found");
     }
 }
开发者ID:ZeroTull,项目名称:ExpenceIt_Automation,代码行数:13,代码来源:Helper.cs


注:本文中的this.Click方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。